diff options
| author | Tim Keller <tjk@tjkeller.xyz> | 2026-05-21 22:55:23 -0500 |
|---|---|---|
| committer | Tim Keller <tjk@tjkeller.xyz> | 2026-05-21 22:55:23 -0500 |
| commit | e918c6ccbcfe19c73cffbdecac2e2ea10479e7e0 (patch) | |
| tree | 8b105585e3ba3cadb7116a32712c13e99c474381 /hosts/hp-envy-office/ups.nix | |
| parent | 6055a9d94861e865ed293c7babd033e30777b002 (diff) | |
| download | nixos-e918c6ccbcfe19c73cffbdecac2e2ea10479e7e0.tar.xz nixos-e918c6ccbcfe19c73cffbdecac2e2ea10479e7e0.zip | |
office ups experimental setupoffice-ups
Diffstat (limited to 'hosts/hp-envy-office/ups.nix')
| -rw-r--r-- | hosts/hp-envy-office/ups.nix | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/hosts/hp-envy-office/ups.nix b/hosts/hp-envy-office/ups.nix new file mode 100644 index 0000000..8af0bcd --- /dev/null +++ b/hosts/hp-envy-office/ups.nix @@ -0,0 +1,85 @@ +let + passwordFile = builtins.toFile "password" "password"; +in { + power.ups = { + enable = true; + ups."UPS-1" = { + driver = "usbhid-ups"; + port = "auto"; + directives = [ + "offdelay = 360" + "ondelay = 370" + "lowbatt = 40" + "ignorelb" + ]; + }; + upsd = { + listen = [ + { + address = "127.0.0.1"; + port = 3493; + } + { + address = "::1"; + port = 3493; + } + ]; + }; + users."nut-admin" = { + # A file that contains just the password. + inherit passwordFile; + upsmon = "primary"; + }; + upsmon.monitor."UPS-1" = { + inherit passwordFile; + system = "UPS-1@localhost"; + powerValue = 1; + user = "nut-admin"; + type = "primary"; + }; + upsmon.settings = { + # This configuration file declares how upsmon is to handle + # NOTIFY events. + + # POWERDOWNFLAG and SHUTDOWNCMD is provided by NixOS default + # values + + # values provided by ConfigExamples 3.0 book + NOTIFYMSG = [ + [ "ONLINE" ''"UPS %s: On line power."'' ] + [ "ONBATT" ''"UPS %s: On battery."'' ] + [ "LOWBATT" ''"UPS %s: Battery is low."'' ] + [ "REPLBATT" ''"UPS %s: Battery needs to be replaced."'' ] + [ "FSD" ''"UPS %s: Forced shutdown in progress."'' ] + [ "SHUTDOWN" ''"Auto logout and shutdown proceeding."'' ] + [ "COMMOK" ''"UPS %s: Communications (re-)established."'' ] + [ "COMMBAD" ''"UPS %s: Communications lost."'' ] + [ "NOCOMM" ''"UPS %s: Not available."'' ] + [ "NOPARENT" ''"upsmon parent dead, shutdown impossible."'' ] + ]; + NOTIFYFLAG = [ + [ "ONLINE" "SYSLOG+WALL" ] + [ "ONBATT" "SYSLOG+WALL" ] + [ "LOWBATT" "SYSLOG+WALL" ] + [ "REPLBATT" "SYSLOG+WALL" ] + [ "FSD" "SYSLOG+WALL" ] + [ "SHUTDOWN" "SYSLOG+WALL" ] + [ "COMMOK" "SYSLOG+WALL" ] + [ "COMMBAD" "SYSLOG+WALL" ] + [ "NOCOMM" "SYSLOG+WALL" ] + [ "NOPARENT" "SYSLOG+WALL" ] + ]; + # every RBWARNTIME seconds, upsmon will generate a replace + # battery NOTIFY event + RBWARNTIME = 216000; + # every NOCOMMWARNTIME seconds, upsmon will generate a UPS + # unreachable NOTIFY event + NOCOMMWARNTIME = 300; + # after sending SHUTDOWN NOTIFY event to warn users, upsmon + # waits FINALDELAY seconds long before executing SHUTDOWNCMD + # Some UPS's don't give much warning for low battery and will + # require a value of 0 here for aq safe shutdown. + FINALDELAY = 0; + }; + }; +} |
