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