1{ config, lib, pkgs, options }: 2 3with lib; 4 5let 6 cfg = config.services.prometheus.exporters.pihole; 7in 8{ 9 imports = [ 10 (mkRemovedOptionModule [ "interval"] "This option has been removed.") 11 ({ options.warnings = options.warnings; options.assertions = options.assertions; }) 12 ]; 13 14 port = 9617; 15 extraOpts = { 16 apiToken = mkOption { 17 type = types.str; 18 default = ""; 19 example = "580a770cb40511eb85290242ac130003580a770cb40511eb85290242ac130003"; 20 description = lib.mdDoc '' 21 Pi-Hole API token which can be used instead of a password 22 ''; 23 }; 24 password = mkOption { 25 type = types.str; 26 default = ""; 27 example = "password"; 28 description = lib.mdDoc '' 29 The password to login into Pi-Hole. An api token can be used instead. 30 ''; 31 }; 32 piholeHostname = mkOption { 33 type = types.str; 34 default = "pihole"; 35 example = "127.0.0.1"; 36 description = lib.mdDoc '' 37 Hostname or address where to find the Pi-Hole webinterface 38 ''; 39 }; 40 piholePort = mkOption { 41 type = types.port; 42 default = 80; 43 example = 443; 44 description = lib.mdDoc '' 45 The port Pi-Hole webinterface is reachable on 46 ''; 47 }; 48 protocol = mkOption { 49 type = types.enum [ "http" "https" ]; 50 default = "http"; 51 example = "https"; 52 description = lib.mdDoc '' 53 The protocol which is used to connect to Pi-Hole 54 ''; 55 }; 56 timeout = mkOption { 57 type = types.str; 58 default = "5s"; 59 description = lib.mdDoc '' 60 Controls the timeout to connect to a Pi-Hole instance 61 ''; 62 }; 63 }; 64 serviceOpts = { 65 serviceConfig = { 66 ExecStart = '' 67 ${pkgs.prometheus-pihole-exporter}/bin/pihole-exporter \ 68 ${optionalString (cfg.apiToken != "") "-pihole_api_token ${cfg.apiToken}"} \ 69 -pihole_hostname ${cfg.piholeHostname} \ 70 ${optionalString (cfg.password != "") "-pihole_password ${cfg.password}"} \ 71 -pihole_port ${toString cfg.piholePort} \ 72 -pihole_protocol ${cfg.protocol} \ 73 -port ${toString cfg.port} \ 74 -timeout ${cfg.timeout} 75 ''; 76 }; 77 }; 78}