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; }; }; }