{ config, lib, ... }: with lib; let cfg = config.local.hardware.apc; in { options.local.hardware.apc = { enable = mkEnableOption "APC UPS support"; }; config = mkIf cfg.enable { services.apcupsd = { enable = true; configText = concatStrings (mapAttrsToList (k: v: "${k} ${v}\n") { UPSMODE = "disable"; UPSTYPE = "usb"; UPSCABLE = "usb"; UPSCLASS = "standalone"; NISIP = "127.0.0.1"; NETSERVER = "on"; MINUTES = "5"; BATTERYLEVEL = "10"; NOLOGON = "disable"; }); }; }; }