mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-20 04:19:00 +02:00
nixos/nix-channel: replace activationScript via tmpfiles
This commit is contained in:
parent
a8f50f9919
commit
cb08d3dd72
|
@ -97,12 +97,9 @@ in
|
|||
|
||||
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.
|
||||
if [ ! -e "/root/.nix-channels" ]; then
|
||||
echo "${config.system.defaultChannel} nixos" > "/root/.nix-channels"
|
||||
fi
|
||||
'');
|
||||
systemd.tmpfiles.rules = lib.mkIf cfg.channel.enable [
|
||||
"f /root/.nix-channels -"
|
||||
''w "/root/.nix-channels" - - - - "${config.system.defaultChannel} nixos\n"''
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
16
nixos/tests/activation/nix-channel.nix
Normal file
16
nixos/tests/activation/nix-channel.nix
Normal file
|
@ -0,0 +1,16 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
|
||||
name = "activation-nix-channel";
|
||||
|
||||
meta.maintainers = with lib.maintainers; [ nikstur ];
|
||||
|
||||
nodes.machine = {
|
||||
nix.channel.enable = true;
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
print(machine.succeed("cat /root/.nix-channels"))
|
||||
'';
|
||||
}
|
|
@ -265,6 +265,7 @@ in {
|
|||
etc = pkgs.callPackage ../modules/system/etc/test.nix { inherit evalMinimalConfig; };
|
||||
activation = pkgs.callPackage ../modules/system/activation/test.nix { };
|
||||
activation-var = runTest ./activation/var.nix;
|
||||
activation-nix-channel = runTest ./activation/nix-channel.nix;
|
||||
etcd = handleTestOn ["x86_64-linux"] ./etcd.nix {};
|
||||
etcd-cluster = handleTestOn ["x86_64-linux"] ./etcd-cluster.nix {};
|
||||
etebase-server = handleTest ./etebase-server.nix {};
|
||||
|
|
Loading…
Reference in a new issue