summaryrefslogtreecommitdiff
path: root/modules/nixos/personal/nix.nix
diff options
context:
space:
mode:
authoraristote <quentin.aristote@irif.fr>2025-02-28 16:32:21 +0100
committeraristote <quentin.aristote@irif.fr>2025-02-28 16:51:20 +0100
commit1c53bf43d1e752cc76e0aac74ac6460a200bc0f6 (patch)
tree50f947e3f5b92e59eda400d6e9b47b5d4f02cdd8 /modules/nixos/personal/nix.nix
parent2f864beb9c0910d36c386571a89fff227d43cd34 (diff)
nixos: unattended decrypt: switch to initrd key
Diffstat (limited to 'modules/nixos/personal/nix.nix')
-rw-r--r--modules/nixos/personal/nix.nix19
1 files changed, 7 insertions, 12 deletions
diff --git a/modules/nixos/personal/nix.nix b/modules/nixos/personal/nix.nix
index a5c6e77..1fd3eec 100644
--- a/modules/nixos/personal/nix.nix
+++ b/modules/nixos/personal/nix.nix
@@ -117,6 +117,7 @@ in {
})
(lib.mkIf cfg.autoUpgrade.enable {
+ personal.boot.unattendedReboot = lib.mkIf config.system.autoUpgrade.allowReboot true;
system.autoUpgrade = {
enable = true;
flake = cfg.flake;
@@ -137,22 +138,16 @@ in {
in
lib.mkIf (cryptExists && config.system.autoUpgrade.allowReboot) {
script = lib.mkAfter ''
- # clean previous keyfile
- # shouldn't do anything, only in case something went wrong
- ${cryptCfg.postOpenCommands}
- # Creating temporary LUKS key file for next reboot...
- if [[ "''${booted}" != "''${built}" && "''${do_reboot}" = true ]]
- then
- # dd if=/dev/urandom of=/boot/keyfile bs=1024 count=4
- # chmod 400 /boot/keyfile
- # cryptsetup --verbose luksAddKey --key-file /etc/luks/keyfile ${cryptCfg.device} /boot/keyfile
- fi
+ cryptsetup --verbose luksAddKey --key-file /etc/luks/keys/master ${cryptCfg.device} /etc/luks/keys/tmp
'';
postStop = ''
# if a reboot due to nixos-upgrade happens, it should occur within a minute
sleep 120
- # if no reboot has happened, clean any leftover keyfile
- ${cryptCfg.postOpenCommands}
+ # if no reboot has happened, disable any leftover keyfile
+ while cryptsetup --verbose luksRemoveKey ${cryptCfg.device} --key-file /etc/luks/keys/tmp
+ do
+ :
+ done
'';
})
];