home-manager: allow a user-defined third module path
The user-defined path will be used if present, otherwise the two "fallback" defaults (in `.nixpkgs` and `.config/nixpkgs`) will be used.
This commit is contained in:
parent
98c7b23178
commit
28d3f74614
|
@ -1,4 +1,10 @@
|
||||||
{ pkgs, modulesPath ? "$HOME/.config/nixpkgs/home-manager/modules" }:
|
{ pkgs
|
||||||
|
|
||||||
|
# Extra path to the Home Manager modules. If set then this path will
|
||||||
|
# be tried before `$HOME/.config/nixpkgs/home-manager/modules` and
|
||||||
|
# `$HOME/.nixpkgs/home-manager/modules`.
|
||||||
|
, modulesPath ? null
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -16,6 +22,8 @@ let
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
modulesPathStr = if modulesPath == null then "" else modulesPath;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
pkgs.stdenv.mkDerivation {
|
pkgs.stdenv.mkDerivation {
|
||||||
|
@ -29,7 +37,7 @@ pkgs.stdenv.mkDerivation {
|
||||||
substituteInPlace $out/bin/home-manager \
|
substituteInPlace $out/bin/home-manager \
|
||||||
--subst-var-by bash "${pkgs.bash}" \
|
--subst-var-by bash "${pkgs.bash}" \
|
||||||
--subst-var-by coreutils "${pkgs.coreutils}" \
|
--subst-var-by coreutils "${pkgs.coreutils}" \
|
||||||
--subst-var-by MODULES_PATH '${modulesPath}' \
|
--subst-var-by MODULES_PATH '${modulesPathStr}' \
|
||||||
--subst-var-by HOME_MANAGER_EXPR_PATH "${homeManagerExpr}"
|
--subst-var-by HOME_MANAGER_EXPR_PATH "${homeManagerExpr}"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ function setConfigFile() {
|
||||||
function setHomeManagerModulesPath() {
|
function setHomeManagerModulesPath() {
|
||||||
local modulesPath
|
local modulesPath
|
||||||
for modulesPath in "@MODULES_PATH@" \
|
for modulesPath in "@MODULES_PATH@" \
|
||||||
|
"$HOME/.config/nixpkgs/home-manager/modules" \
|
||||||
"$HOME/.nixpkgs/home-manager/modules" ; do
|
"$HOME/.nixpkgs/home-manager/modules" ; do
|
||||||
if [[ -e "$modulesPath" ]] ; then
|
if [[ -e "$modulesPath" ]] ; then
|
||||||
export NIX_PATH="$NIX_PATH${NIX_PATH:+:}home-manager=$modulesPath"
|
export NIX_PATH="$NIX_PATH${NIX_PATH:+:}home-manager=$modulesPath"
|
||||||
|
|
Loading…
Reference in a new issue