mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
nixos/nix-channel: Take care of NIX_PATH's non-empty default when disabled
This commit is contained in:
parent
d00e242b80
commit
61afc4d166
@ -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.
|
||||
|
@ -338,6 +338,18 @@ let
|
||||
with subtest("nix-channel command is not available anymore"):
|
||||
machine.succeed("! which nix-channel")
|
||||
|
||||
# Note that the channel profile is still present on disk, but configured
|
||||
# not to be used.
|
||||
with subtest("builtins.nixPath is now empty"):
|
||||
machine.succeed("""
|
||||
[[ "[ ]" == "$(nix-instantiate builtins.nixPath --eval --expr)" ]]
|
||||
""")
|
||||
|
||||
with subtest("<nixpkgs> does not resolve"):
|
||||
machine.succeed("""
|
||||
! nix-instantiate '<nixpkgs>' --eval --expr
|
||||
""")
|
||||
|
||||
with subtest("Evaluate flake config in fresh env without nix-channel"):
|
||||
machine.succeed("nixos-rebuild switch --flake /root/my-config#xyz")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user