1{ 2 config, 3 lib, 4 pkgs, 5 options, 6 ... 7}: 8 9let 10 cfg = config.services.prometheus.exporters.idrac; 11 inherit (lib) mkOption types; 12 13 configFile = 14 if cfg.configurationPath != null then 15 cfg.configurationPath 16 else 17 pkgs.writeText "idrac.yml" (builtins.toJSON cfg.configuration); 18in 19{ 20 port = 9348; 21 extraOpts = { 22 configurationPath = mkOption { 23 type = with types; nullOr path; 24 default = null; 25 example = "/etc/prometheus-idrac-exporter/idrac.yml"; 26 description = '' 27 Path to the service's config file. This path can either be a computed path in /nix/store or a path in the local filesystem. 28 29 The config file should NOT be stored in /nix/store as it will contain passwords and/or keys in plain text. 30 31 Mutually exclusive with `configuration` option. 32 33 Configuration reference: <https://github.com/mrlhansen/idrac_exporter/#configuration> 34 ''; 35 }; 36 configuration = mkOption { 37 type = types.nullOr types.attrs; 38 description = '' 39 Configuration for iDRAC exporter, as a nix attribute set. 40 41 Configuration reference: <https://github.com/mrlhansen/idrac_exporter/#configuration> 42 43 Mutually exclusive with `configurationPath` option. 44 ''; 45 default = null; 46 example = { 47 timeout = 10; 48 retries = 1; 49 hosts = { 50 default = { 51 username = "username"; 52 password = "password"; 53 }; 54 }; 55 metrics = { 56 system = true; 57 sensors = true; 58 power = true; 59 sel = true; 60 storage = true; 61 memory = true; 62 }; 63 }; 64 }; 65 }; 66 67 serviceOpts = { 68 serviceConfig = { 69 LoadCredential = "configFile:${configFile}"; 70 ExecStart = "${pkgs.prometheus-idrac-exporter}/bin/idrac_exporter -config %d/configFile"; 71 Environment = [ 72 "IDRAC_EXPORTER_LISTEN_ADDRESS=${cfg.listenAddress}" 73 "IDRAC_EXPORTER_LISTEN_PORT=${toString cfg.port}" 74 ]; 75 }; 76 }; 77}