summary refs log tree commit diff
path: root/nixos/modules/config
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2023-07-07 23:12:39 +0200
committerRobert Hensing <robert@roberthensing.nl>2023-07-07 23:12:39 +0200
commit61afc4d1662fe426f02b28e386f2e053f887b6d6 (patch)
tree537bc98140027a2103caaf701788b1ab87591c2d /nixos/modules/config
parentd00e242b805a5580e542dd5fb7c6b3e035be8697 (diff)
downloadnixpkgs-61afc4d1662fe426f02b28e386f2e053f887b6d6.tar
nixpkgs-61afc4d1662fe426f02b28e386f2e053f887b6d6.tar.gz
nixpkgs-61afc4d1662fe426f02b28e386f2e053f887b6d6.tar.bz2
nixpkgs-61afc4d1662fe426f02b28e386f2e053f887b6d6.tar.lz
nixpkgs-61afc4d1662fe426f02b28e386f2e053f887b6d6.tar.xz
nixpkgs-61afc4d1662fe426f02b28e386f2e053f887b6d6.tar.zst
nixpkgs-61afc4d1662fe426f02b28e386f2e053f887b6d6.zip
nixos/nix-channel: Take care of NIX_PATH's non-empty default when disabled
Diffstat (limited to 'nixos/modules/config')
-rw-r--r--nixos/modules/config/nix-channel.nix7
1 files changed, 6 insertions, 1 deletions
diff --git a/nixos/modules/config/nix-channel.nix b/nixos/modules/config/nix-channel.nix
index f211b3dbe28..f90da62ec83 100644
--- a/nixos/modules/config/nix-channel.nix
+++ b/nixos/modules/config/nix-channel.nix
@@ -9,6 +9,7 @@
 { config, lib, ... }:
 let
   inherit (lib)
+    mkDefault
     mkIf
     mkOption
     stringAfter
@@ -88,10 +89,14 @@ in
       rm $out/bin/nix-channel
     '';
 
-    environment.sessionVariables = mkIf (cfg.nixPath != []) {
+    # NIX_PATH has a non-empty default according to Nix docs, so we don't unset
+    # it when empty.
+    environment.sessionVariables = {
       NIX_PATH = cfg.nixPath;
     };
 
+    nix.settings.nix-path = mkIf (! cfg.channel.enable) (mkDefault "");
+
     system.activationScripts.nix-channel = mkIf cfg.channel.enable
       (stringAfter [ "etc" "users" ] ''
         # Subscribe the root user to the NixOS channel by default.