diff options
Diffstat (limited to 'nixos/modules/config/nix-channel.nix')
-rw-r--r-- | nixos/modules/config/nix-channel.nix | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/nixos/modules/config/nix-channel.nix b/nixos/modules/config/nix-channel.nix index 8e6061e4956..c37c3f73c30 100644 --- a/nixos/modules/config/nix-channel.nix +++ b/nixos/modules/config/nix-channel.nix @@ -12,6 +12,22 @@ let in { options = { + nix = { + nixPath = mkOption { + type = types.listOf types.str; + default = [ + "nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos" + "nixos-config=/etc/nixos/configuration.nix" + "/nix/var/nix/profiles/per-user/root/channels" + ]; + description = lib.mdDoc '' + The default Nix expression search path, used by the Nix + evaluator to look up paths enclosed in angle brackets + (e.g. `<nixpkgs>`). + ''; + }; + }; + system = { defaultChannel = mkOption { internal = true; @@ -24,6 +40,17 @@ in config = mkIf cfg.enable { + environment.extraInit = + '' + if [ -e "$HOME/.nix-defexpr/channels" ]; then + export NIX_PATH="$HOME/.nix-defexpr/channels''${NIX_PATH:+:$NIX_PATH}" + fi + ''; + + environment.sessionVariables = { + NIX_PATH = cfg.nixPath; + }; + system.activationScripts.nix-channel = stringAfter [ "etc" "users" ] '' # Subscribe the root user to the NixOS channel by default. |