1 { config, lib, pkgs, ... }:
3 cfg = config.services.prometheus.exporters.dnssec;
4 configFormat = pkgs.formats.toml { };
5 configFile = configFormat.generate "dnssec-checks.toml" cfg.configuration;
9 configuration = lib.mkOption {
10 type = lib.types.nullOr lib.types.attrs;
13 dnssec exporter configuration as nix attribute set.
15 See <https://github.com/chrj/prometheus-dnssec-exporter/blob/master/README.md>
16 for the description of the configuration file format.
18 example = lib.literalExpression ''
27 zone = "verisigninc.com";
36 listenAddress = lib.mkOption {
37 type = lib.types.nullOr lib.types.str;
40 Listen address as host IP and port definition.
45 resolvers = lib.mkOption {
46 type = lib.types.listOf lib.types.str;
49 DNSSEC capable resolver to be used for the check.
51 example = [ "0.0.0.0:53" ];
54 timeout = lib.mkOption {
55 type = lib.types.nullOr lib.types.str;
58 DNS request timeout duration.
63 extraFlags = lib.mkOption {
64 type = lib.types.listOf lib.types.str;
67 Extra commandline options when launching Prometheus.
74 startScript = pkgs.writeShellScriptBin "prometheus-dnssec-exporter-start"
75 "${lib.concatStringsSep " "
76 ([ "${pkgs.prometheus-dnssec-exporter}/bin/prometheus-dnssec-exporter" ]
77 ++ lib.optionals (cfg.configuration != null)
78 [ "-config ${configFile}" ]
79 ++ lib.optionals (cfg.listenAddress != null)
80 [ "-listen-address ${lib.escapeShellArg cfg.listenAddress}" ]
81 ++ lib.optionals (cfg.resolvers != [ ]) [
83 lib.escapeShellArg (lib.concatStringsSep "," cfg.resolvers)
85 ] ++ lib.optionals (cfg.timeout != null)
86 [ "-timeout ${lib.escapeShellArg cfg.timeout}" ] ++ cfg.extraFlags)}";
87 in { ExecStart = lib.getExe startScript; };