Update configuration.nix

This commit is contained in:
ska
2025-12-22 15:14:43 +00:00
parent e3a2db0c4c
commit 6817b784ea

View File

@@ -218,23 +218,23 @@
############################################################ ############################################################
systemd.services.usb-root-monitor = { systemd.services.usb-root-monitor = {
description = "Monitor USB root device and shut down if removed"; description = "Monitor USB LUKS container and shut down if removed";
script = '' script = ''
LUksDevice="/dev/disk/by-partlabel/nixos-crypt"
while true; do while true; do
if ! test -e /dev/disk/by-label/nixos-root; then if ! test -e "$LUksDevice"; then
/run/current-system/sw/bin/logger -t usb-root-monitor "Root device missing shutting down" /run/current-system/sw/bin/logger -t usb-root-monitor "LUKS container missing shutting down immediately"
/run/current-system/sw/bin/systemctl poweroff /run/current-system/sw/bin/systemctl --force poweroff
exit 0 exit 0
fi fi
sleep 5 sleep 3
done done
''; '';
serviceConfig = { serviceConfig = {
Type = "simple"; Type = "simple";
Restart = "always"; Restart = "always";
RestartSec = 10; RestartSec = 5;
User = "root"; User = "root";
ExecStop = "/run/current-system/sw/bin/kill $MAINPID";
}; };
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
}; };