diff options
author | Robert Hensing <robert@roberthensing.nl> | 2023-07-05 14:05:41 +0200 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2023-07-05 14:54:29 +0200 |
commit | fad172a36672161235efec7b118e2240deaabd76 (patch) | |
tree | 25d70f8e67f23ae8183f5498813f925f39610d98 /nixos/modules/config | |
parent | 5c0c96a8283de416891bb4f8fd67c6e5693ac1a2 (diff) | |
download | nixpkgs-fad172a36672161235efec7b118e2240deaabd76.tar nixpkgs-fad172a36672161235efec7b118e2240deaabd76.tar.gz nixpkgs-fad172a36672161235efec7b118e2240deaabd76.tar.bz2 nixpkgs-fad172a36672161235efec7b118e2240deaabd76.tar.lz nixpkgs-fad172a36672161235efec7b118e2240deaabd76.tar.xz nixpkgs-fad172a36672161235efec7b118e2240deaabd76.tar.zst nixpkgs-fad172a36672161235efec7b118e2240deaabd76.zip |
nixos/config/nix-channel: Move NIX_PATH logic
Diffstat (limited to 'nixos/modules/config')
-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. |