From f4083c40b6a312db6c293f345b556066523f5d49 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Mon, 27 Jun 2022 20:47:18 +0200 Subject: pkgs/profpatsch/deploy: Also create system profile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 ) --- pkgs/profpatsch/deploy.nix | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'pkgs/profpatsch') 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 { -- cgit 1.4.1