summaryrefslogtreecommitdiff
path: root/sys/hardware/apc.nix
blob: 9614c489a7136904a647f687e8110eef92ba59b7 (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
{ 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";
      });
    };
  };
}