From 7d0b5b3a94afcb751e4e79ec83f9ee8e3c5b8a0b Mon Sep 17 00:00:00 2001 From: nikstur Date: Wed, 1 Nov 2023 16:01:49 +0100 Subject: [PATCH] nixos/nix-channnel: fix setting up the default channel again --- nixos/modules/config/nix-channel.nix | 3 +-- nixos/tests/activation/nix-channel.nix | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/nixos/modules/config/nix-channel.nix b/nixos/modules/config/nix-channel.nix index 0565c9cc8dad..a7ca7a5c74a4 100644 --- a/nixos/modules/config/nix-channel.nix +++ b/nixos/modules/config/nix-channel.nix @@ -98,8 +98,7 @@ in 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'' + ''f /root/.nix-channels - - - - ${config.system.defaultChannel} nixos\n'' ]; }; } diff --git a/nixos/tests/activation/nix-channel.nix b/nixos/tests/activation/nix-channel.nix index a01a66ebc1bf..d26ea98e56cc 100644 --- a/nixos/tests/activation/nix-channel.nix +++ b/nixos/tests/activation/nix-channel.nix @@ -11,7 +11,16 @@ }; 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" ''; }