1{ config, lib, pkgs, options }:
2
3with lib;
4
5let
6 logPrefix = "services.prometheus.exporter.ipmi";
7 cfg = config.services.prometheus.exporters.ipmi;
8in {
9 port = 9290;
10
11 extraOpts = {
12 configFile = mkOption {
13 type = types.nullOr types.path;
14 default = null;
15 description = lib.mdDoc ''
16 Path to configuration file.
17 '';
18 };
19
20 webConfigFile = mkOption {
21 type = types.nullOr types.path;
22 default = null;
23 description = lib.mdDoc ''
24 Path to configuration file that can enable TLS or authentication.
25 '';
26 };
27 };
28
29 serviceOpts.serviceConfig = {
30 ExecStart = with cfg; concatStringsSep " " ([
31 "${pkgs.prometheus-ipmi-exporter}/bin/ipmi_exporter"
32 "--web.listen-address ${listenAddress}:${toString port}"
33 ] ++ optionals (cfg.webConfigFile != null) [
34 "--web.config.file ${escapeShellArg cfg.webConfigFile}"
35 ] ++ optionals (cfg.configFile != null) [
36 "--config.file ${escapeShellArg cfg.configFile}"
37 ] ++ extraFlags);
38
39 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
40 RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ];
41 };
42}