nixos/nix-channnel: fix setting up the default channel again

nikstur 7d0b5b3a d64dbf72

Changed files
+10 -2
nixos
modules
tests
activation
+1 -2
nixos/modules/config/nix-channel.nix
···
nix.settings.nix-path = mkIf (! cfg.channel.enable) (mkDefault "");
systemd.tmpfiles.rules = lib.mkIf cfg.channel.enable [
-
"f /root/.nix-channels -"
-
''w+ "/root/.nix-channels" - - - - ${config.system.defaultChannel} nixos\n''
];
};
}
···
nix.settings.nix-path = mkIf (! cfg.channel.enable) (mkDefault "");
systemd.tmpfiles.rules = lib.mkIf cfg.channel.enable [
+
''f /root/.nix-channels - - - - ${config.system.defaultChannel} nixos\n''
];
};
}
+9
nixos/tests/activation/nix-channel.nix
···
};
testScript = { nodes, ... }: ''
assert machine.succeed("cat /root/.nix-channels") == "${nodes.machine.system.defaultChannel} nixos\n"
'';
}
···
};
testScript = { nodes, ... }: ''
+
machine.start(allow_reboot=True)
+
assert machine.succeed("cat /root/.nix-channels") == "${nodes.machine.system.defaultChannel} nixos\n"
+
+
nixpkgs_unstable_channel = "https://nixos.org/channels/nixpkgs-unstable nixpkgs"
+
machine.succeed(f"echo '{nixpkgs_unstable_channel}' > /root/.nix-channels")
+
+
machine.reboot()
+
+
assert machine.succeed("cat /root/.nix-channels") == f"{nixpkgs_unstable_channel}\n"
'';
}