From 0b2d28d61753eefcbc599ea8025f09afeaa6ed9e Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Mon, 18 Aug 2025 10:10:29 -0400 Subject: [PATCH] ups: init --- configuration.nix | 2 ++ services/ups.nix | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 services/ups.nix diff --git a/configuration.nix b/configuration.nix index ca98733..7ce9232 100644 --- a/configuration.nix +++ b/configuration.nix @@ -30,6 +30,8 @@ ./services/soulseek.nix # ./services/llama-cpp.nix + + ./services/ups.nix ]; systemd.targets = { diff --git a/services/ups.nix b/services/ups.nix new file mode 100644 index 0000000..b7c19d5 --- /dev/null +++ b/services/ups.nix @@ -0,0 +1,22 @@ +{ + config, + lib, + pkgs, + ... +}: +{ + services.apcupsd = { + enable = true; + configText = '' + UPSTYPE usb + NISIP 127.0.0.1 + BATTERYLEVEL 5 # shutdown after reaching 5% battery + MINUTES 5 # shutdown if estimated runtime on battery reaches 5 minutes + ''; + + hooks = { + # command to run when shutdown condition is met + doshutdown = "systemctl poweroff"; + }; + }; +}