1{ config, lib, pkgs, options }:
2
3with lib;
4
5let
6 cfg = config.services.prometheus.exporters.dnsmasq;
7in
8{
9 port = 9153;
10 extraOpts = {
11 dnsmasqListenAddress = mkOption {
12 type = types.str;
13 default = "localhost:53";
14 description = lib.mdDoc ''
15 Address on which dnsmasq listens.
16 '';
17 };
18 leasesPath = mkOption {
19 type = types.path;
20 default = "/var/lib/misc/dnsmasq.leases";
21 example = "/var/lib/dnsmasq/dnsmasq.leases";
22 description = lib.mdDoc ''
23 Path to the `dnsmasq.leases` file.
24 '';
25 };
26 };
27 serviceOpts = {
28 serviceConfig = {
29 ExecStart = ''
30 ${pkgs.prometheus-dnsmasq-exporter}/bin/dnsmasq_exporter \
31 --listen ${cfg.listenAddress}:${toString cfg.port} \
32 --dnsmasq ${cfg.dnsmasqListenAddress} \
33 --leases_path ${escapeShellArg cfg.leasesPath} \
34 ${concatStringsSep " \\\n " cfg.extraFlags}
35 '';
36 };
37 };
38}