summary refs log tree commit diff
path: root/nixos/modules/config
diff options
context:
space:
mode:
authornikstur <nikstur@outlook.com>2023-10-17 21:39:51 +0200
committernikstur <nikstur@outlook.com>2023-10-25 23:43:58 +0200
commitcb08d3dd72f51fd20d26c823204faa11d742cfe1 (patch)
treeb3a9b28fdbd7463541bdd53e3e44467bf38b9472 /nixos/modules/config
parenta8f50f991948b91d1a191d1348bfff860a39b5a2 (diff)
downloadnixpkgs-cb08d3dd72f51fd20d26c823204faa11d742cfe1.tar
nixpkgs-cb08d3dd72f51fd20d26c823204faa11d742cfe1.tar.gz
nixpkgs-cb08d3dd72f51fd20d26c823204faa11d742cfe1.tar.bz2
nixpkgs-cb08d3dd72f51fd20d26c823204faa11d742cfe1.tar.lz
nixpkgs-cb08d3dd72f51fd20d26c823204faa11d742cfe1.tar.xz
nixpkgs-cb08d3dd72f51fd20d26c823204faa11d742cfe1.tar.zst
nixpkgs-cb08d3dd72f51fd20d26c823204faa11d742cfe1.zip
nixos/nix-channel: replace activationScript via tmpfiles
Diffstat (limited to 'nixos/modules/config')
-rw-r--r--nixos/modules/config/nix-channel.nix11
1 files changed, 4 insertions, 7 deletions
diff --git a/nixos/modules/config/nix-channel.nix b/nixos/modules/config/nix-channel.nix
index 3f8e088ede9..4abc846b085 100644
--- a/nixos/modules/config/nix-channel.nix
+++ b/nixos/modules/config/nix-channel.nix
@@ -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"''
+    ];
   };
 }