@@ -0,0 +1,50 @@
1+{ config, lib, pkgs, options }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.prometheus.exporters.knot;
7+in {
8+ port = 9433;
9+ extraOpts = {
10+ knotLibraryPath = mkOption {
11+ type = types.str;
12+ default = "${pkgs.knot-dns.out}/lib/libknot.so";
13+ defaultText = "\${pkgs.knot-dns}/lib/libknot.so";
14+ description = ''
15+ Path to the library of <package>knot-dns</package>.
16+ '';
17+ };
18+
19+ knotSocketPath = mkOption {
20+ type = types.str;
21+ default = "/run/knot/knot.sock";
22+ description = ''
23+ Socket path of <citerefentry><refentrytitle>knotd</refentrytitle>
24+ <manvolnum>8</manvolnum></citerefentry>.
25+ '';
26+ };
27+
28+ knotSocketTimeout = mkOption {
29+ type = types.int;
30+ default = 2000;
31+ description = ''
32+ Timeout in seconds.
33+ '';
34+ };
35+ };
36+ serviceOpts = {
37+ serviceConfig = {
38+ ExecStart = ''
39+ ${pkgs.prometheus-knot-exporter}/bin/knot_exporter \
40+ --web-listen-addr ${cfg.listenAddress} \
41+ --web-listen-port ${toString cfg.port} \
42+ --knot-library-path ${cfg.knotLibraryPath} \
43+ --knot-socket-path ${cfg.knotSocketPath} \
44+ --knot-socket-timeout ${toString cfg.knotSocketTimeout} \
45+ ${concatStringsSep " \\\n " cfg.extraFlags}
46+ '';
47+ SupplementaryGroups = [ "knot" ];
48+ };
49+ };
50+}