1{ 2 config, 3 lib, 4 pkgs, 5 options, 6 ... 7}: 8 9let 10 cfg = config.services.prometheus.exporters.apcupsd; 11 inherit (lib) mkOption types concatStringsSep; 12in 13{ 14 port = 9162; 15 extraOpts = { 16 apcupsdAddress = mkOption { 17 type = types.str; 18 default = ":3551"; 19 description = '' 20 Address of the apcupsd Network Information Server (NIS). 21 ''; 22 }; 23 24 apcupsdNetwork = mkOption { 25 type = types.enum [ 26 "tcp" 27 "tcp4" 28 "tcp6" 29 ]; 30 default = "tcp"; 31 description = '' 32 Network of the apcupsd Network Information Server (NIS): one of "tcp", "tcp4", or "tcp6". 33 ''; 34 }; 35 }; 36 serviceOpts = { 37 serviceConfig = { 38 ExecStart = '' 39 ${pkgs.prometheus-apcupsd-exporter}/bin/apcupsd_exporter \ 40 -telemetry.addr ${cfg.listenAddress}:${toString cfg.port} \ 41 -apcupsd.addr ${cfg.apcupsdAddress} \ 42 -apcupsd.network ${cfg.apcupsdNetwork} \ 43 ${concatStringsSep " \\\n " cfg.extraFlags} 44 ''; 45 }; 46 }; 47}