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 | |
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
-rw-r--r-- | nixos/modules/config/nix-channel.nix | 27 | ||||
-rw-r--r-- | nixos/modules/services/misc/nix-daemon.nix | 23 |
2 files changed, 28 insertions, 22 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. diff --git a/nixos/modules/services/misc/nix-daemon.nix b/nixos/modules/services/misc/nix-daemon.nix index 4e986b217ef..51b87bf585c 100644 --- a/nixos/modules/services/misc/nix-daemon.nix +++ b/nixos/modules/services/misc/nix-daemon.nix @@ -145,20 +145,6 @@ in you should increase this value. ''; }; - - 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>`). - ''; - }; }; }; @@ -242,14 +228,7 @@ in }; # Set up the environment variables for running Nix. - environment.sessionVariables = cfg.envVars // { NIX_PATH = cfg.nixPath; }; - - environment.extraInit = - '' - if [ -e "$HOME/.nix-defexpr/channels" ]; then - export NIX_PATH="$HOME/.nix-defexpr/channels''${NIX_PATH:+:$NIX_PATH}" - fi - ''; + environment.sessionVariables = cfg.envVars; nix.nrBuildUsers = mkDefault ( if cfg.settings.auto-allocate-uids or false then 0 |