Update configuration.nix
This commit is contained in:
@@ -200,7 +200,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
systemd.timers.nixos-git-update = {
|
systemd.timers.nixos-git-update = {
|
||||||
description = "Check for config updates hourly";
|
description = "Check for config updates at startup";
|
||||||
wantedBy = [ "timers.target" ];
|
wantedBy = [ "timers.target" ];
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
OnBootSec = "60s";
|
OnBootSec = "60s";
|
||||||
@@ -213,6 +213,32 @@
|
|||||||
|
|
||||||
zramSwap.enable = true;
|
zramSwap.enable = true;
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# USB ROOT DEVICE MONITOR (SHUTDOWN ON DISCONNECT)
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
systemd.services.usb-root-monitor = {
|
||||||
|
description = "Monitor USB root device and shut down if removed";
|
||||||
|
script = ''
|
||||||
|
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
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "simple";
|
||||||
|
Restart = "always";
|
||||||
|
RestartSec = 10;
|
||||||
|
User = "root";
|
||||||
|
ExecStop = "/run/current-system/sw/bin/kill $MAINPID";
|
||||||
|
};
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
};
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# NIXOS VERSION
|
# NIXOS VERSION
|
||||||
############################################################
|
############################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user