10 logPrefix = "services.prometheus.exporter.blackbox";
11 cfg = config.services.prometheus.exporters.blackbox;
19 # This ensures that we can deal with string paths, path types and
20 # store-path strings with context.
23 if (builtins.isPath file) || (lib.isStorePath file) then
28 ${logPrefix}: configuration file "${file}" is being copied to the nix-store.
29 If you would like to avoid that, please set enableConfigCheck to false.
35 if lib.hasPrefix "/tmp/" file then
36 throw "${logPrefix}: configuration file must not reside within /tmp - it won't be visible to the systemd service."
41 pkgs.runCommand "checked-blackbox-exporter.conf"
43 preferLocalBuild = true;
44 nativeBuildInputs = [ pkgs.buildPackages.prometheus-blackbox-exporter ];
47 ln -s ${coerceConfigFile file} $out
48 blackbox_exporter --config.check --config.file $out
54 configFile = mkOption {
57 Path to configuration file.
60 enableConfigCheck = mkOption {
64 Whether to run a correctness check for the configuration file. This depends
65 on the configuration file residing in the nix-store. Paths passed as string will
66 be copied to the store.
74 if cfg.enableConfigCheck then checkConfig cfg.configFile else checkConfigLocation cfg.configFile;
78 AmbientCapabilities = [ "CAP_NET_RAW" ]; # for ping probes
80 ${pkgs.prometheus-blackbox-exporter}/bin/blackbox_exporter \
81 --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
82 --config.file ${escapeShellArg adjustedConfigFile} \
83 ${concatStringsSep " \\\n " cfg.extraFlags}
85 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";