about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2022-06-27 20:47:18 +0200
committerProfpatsch <mail@profpatsch.de>2022-06-27 20:47:18 +0200
commitf4083c40b6a312db6c293f345b556066523f5d49 (patch)
tree4324849d785c11d92fd7d2f0f46163a60dce807e /pkgs
parent58909c9ea0a94e464297eaab74d1d5df1c2bc066 (diff)
pkgs/profpatsch/deploy: Also create system profile
I don’t know how I missed this, but my deploy script didn’t actually
set up a system profile, so rebooting would lead to (very) old
generations being activated again.

Thanks to @sternenseemann for the nix-env trick (via
https://code.tvl.fyi/tree/ops/nixos.nix#n55 )
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/profpatsch/deploy.nix17
1 files changed, 13 insertions, 4 deletions
diff --git a/pkgs/profpatsch/deploy.nix b/pkgs/profpatsch/deploy.nix
index ddd6eeac..863fe4c7 100644
--- a/pkgs/profpatsch/deploy.nix
+++ b/pkgs/profpatsch/deploy.nix
@@ -4,7 +4,7 @@
 let
   bins = getBins pkgs.coreutils [ "realpath" ]
       // getBins pkgs.openssh [ "ssh" ]
-      // getBins pkgs.nix [ "nix-build" "nix-copy-closure" ]
+      // getBins pkgs.nix [ "nix-build" "nix-copy-closure" "nix-env" ]
       ;
 
   deploy = pkgs.writers.writeDash "deploy-machine-profpatsch" ''
@@ -21,16 +21,25 @@ let
       -A "machines.profpatsch.$MACHINE.build" \
       "$VUIZVUI"
 
+    # copy all required paths to the machine
     ${bins.nix-copy-closure} \
       --to "$MACHINE?compress=true" \
       --use-substitutes \
+      ${create-system-profile-and-switch} \
       "$OUT_LINK"
 
-
+    # activate the system
     ${bins.ssh} \
       "root@$MACHINE" \
-      "$(${bins.realpath} $OUT_LINK)/bin/switch-to-configuration" \
-      "switch"
+      ${create-system-profile-and-switch} \
+      "$(${bins.realpath} $OUT_LINK)"
+  '';
+
+  create-system-profile-and-switch = pkgs.writers.writeDash "create-system-profile-and-switch" ''
+    set -e
+    system="$1"
+    ${bins.nix-env} -p /nix/var/nix/profiles/system --set $system
+    $system/bin/switch-to-configuration switch
   '';
 
 in {