nix: make channel entries for NIX_PATH dynamic
This avoids warnings like this if the root or user channel profiles
don't exist.
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
This commit is contained in:
parent
79d356909b
commit
95fb1cb2aa
1 changed files with 21 additions and 3 deletions
|
|
@ -315,13 +315,23 @@ in
|
|||
default =
|
||||
[ # Include default path <darwin-config>.
|
||||
"darwin-config=${config.environment.darwinConfig}"
|
||||
"/nix/var/nix/profiles/per-user/root/channels"
|
||||
"$HOME/.nix-defexpr/channels"
|
||||
];
|
||||
description = ''
|
||||
The default Nix expression search path, used by the Nix
|
||||
evaluator to look up paths enclosed in angle brackets
|
||||
(e.g. <literal><nixpkgs></literal>).
|
||||
(e.g. <literal><nixpkgs></literal>). This value gets
|
||||
extended with user and/or root channels if those exist and
|
||||
nix.enableChannels isn't disabled.
|
||||
'';
|
||||
};
|
||||
|
||||
nix.enableChannels = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to extend <envar>NIX_PATH</envar> with <filename>~/.nix-defexpr/channels</filename>
|
||||
and <filename>/nix/var/nix/profiles/per-user/root/channels</filename>
|
||||
if they exist.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
@ -394,6 +404,14 @@ in
|
|||
if [ ! -w /nix/var/nix/db ]; then
|
||||
export NIX_REMOTE=daemon
|
||||
fi
|
||||
'' + optionalString cfg.enableChannels ''
|
||||
# Set up NIX_PATH with root and/or user channels.
|
||||
if [ -d "$HOME/.nix-defexpr/channels" ]; then
|
||||
export NIX_PATH="''${NIX_PATH:+$NIX_PATH:}$HOME/.nix-defexpr/channels"
|
||||
fi
|
||||
if [ -d /nix/var/nix/profiles/per-user/root/channels ]; then
|
||||
export NIX_PATH="''${NIX_PATH:+$NIX_PATH:}/nix/var/nix/profiles/per-user/root/channels"
|
||||
fi
|
||||
'';
|
||||
|
||||
# Set up the environment variables for running Nix.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue