diff options
| author | quentin@aristote.fr <quentin@aristote.fr> | 2025-03-20 07:57:02 +0100 |
|---|---|---|
| committer | quentin@aristote.fr <quentin@aristote.fr> | 2025-03-20 08:07:27 +0100 |
| commit | fbf0dda062005736d802e4357c9fd71277c7eded (patch) | |
| tree | c7154eae1db45f71c6f5e8b035710655c4efda9f /config | |
| parent | c7497cf4c729379c9a07004ed7472489bdc754a7 (diff) | |
autoUpgrade: reboot immediately
Diffstat (limited to 'config')
| -rw-r--r-- | config/nix.nix | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/config/nix.nix b/config/nix.nix index 3989c6e..a5110a6 100644 --- a/config/nix.nix +++ b/config/nix.nix @@ -38,6 +38,8 @@ in { # as remote hephaistos git push --force hephaistos master ''; + postStop = lib.mkForce ""; + serviceConfig.TimeoutStopSec = lib.mkForce (lib.mkOptionDefault ""); script = lib.mkForce (let hephaistos = "hephaistos.aristote.mesh"; in @@ -53,27 +55,29 @@ in { switch = "$RESULT/bin/switch-to-configuration"; readlink = "${pkgs.coreutils}/bin/readlink"; luksCfg = config.boot.initrd.luks.devices; + crypt = luksCfg.crypt.device; in if allowReboot - then - '' - ${switch} boot - booted="$(${readlink} /run/booted-system/{initrd,kernel,kernel-modules})" - built="$(${readlink} /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})" - if [ "$booted" = "$built" ] - then - ${switch} switch - else '' - + lib.optionalString (luksCfg ? crypt) '' - cryptsetup --verbose luksAddKey \ + then '' + ${switch} boot + booted="$(${readlink} /run/booted-system/{initrd,kernel,kernel-modules})" + built="$(${readlink} /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})" + if [ "$booted" = "$built" ] + then + ${switch} switch + else + ${lib.optionalString (luksCfg ? crypt) '' + cryptsetup luksAddKey ${crypt} /etc/luks/keys/tmp \ --key-file /etc/luks/keys/master \ - ${luksCfg.crypt.device} \ - /etc/luks/keys/tmp - '' - + '' - shutdown -r +1 - fi - '' + --verbose + ''} + shutdown -r now ${lib.optionalString (luksCfg ? crypt) '' || \ + cryptsetup luksRemoveKey ${crypt} \ + --key-file /etc/luks/keys/tmp \ + --verbose + ''} + fi + '' else '' ${switch} switch '' |
