summaryrefslogtreecommitdiff
path: root/sys/hardware/apc.nix
blob: 97a5bb097bdd5e58180f3e94afb61c595c5e87d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
  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";
      });
    };
  };
}