From 20d5fa29ae89ab7b0d3b1902a9694ec09f9e3367 Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Thu, 28 Dec 2023 18:33:55 +0000 Subject: [PATCH] nixos/deploy: Minor improvements --- nixos/modules/deploy-rs.nix | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/nixos/modules/deploy-rs.nix b/nixos/modules/deploy-rs.nix index 5b78dfe..9a90f39 100644 --- a/nixos/modules/deploy-rs.nix +++ b/nixos/modules/deploy-rs.nix @@ -15,16 +15,20 @@ let # Based on https://github.com/serokell/deploy-rs/blob/master/flake.nix nixosActivate = cfg': base: (pkgs.deploy-rs.lib.activate.custom // { dryActivate = "$PROFILE/bin/switch-to-configuration dry-activate"; - boot = "$PROFILE/bin/switch-to-configuration boot"; + boot = '' + $PROFILE/bin/switch-to-configuration boot + + ${keepGensSnippet "$PROFILE" cfg'.keepGenerations} + ''; }) base.config.system.build.toplevel '' # work around https://github.com/NixOS/nixpkgs/issues/73404 cd /tmp - "$PROFILE"/bin/switch-to-configuration ${cfg'.mode} + "$PROFILE"/bin/switch-to-configuration switch # https://github.com/serokell/deploy-rs/issues/31 ${with base.config.boot.loader; - optionalString ((cfg'.mode == "switch" || cfg'.mode == "boot") && systemd-boot.enable) + optionalString systemd-boot.enable "sed -i '/^default /d' ${efi.efiSysMountPoint}/loader/loader.conf"} ${keepGensSnippet "$PROFILE" cfg'.keepGenerations} @@ -59,7 +63,11 @@ let { name = "container-${n}"; value = { - path = pkgs.deploy-rs.lib.activate.custom ctrConfig.my.buildAs.container '' + path = (pkgs.deploy-rs.lib.activate.custom // { + boot = '' + echo "Next systemd-nspawn@${n}.service restart / reload will load config" + ''; + }) ctrConfig.my.buildAs.container '' source ${systemdUtil}/bin/systemd-util.sh ${if c.hotReload then '' if (! systemctl show -p ActiveState systemd-nspawn@${n} | grep -q "ActiveState=active") || \