1 { pkgs, lib, config, ... }:
4 inherit (config.services) knot;
5 inherit (config.users) users groups;
10 knot/sourcephile.fr.nix
12 options.services.knot = {
13 zones = lib.mkOption {
15 type = types.attrsOf (types.submodule ({name, ...}: {
16 #config.domain = lib.mkDefault name;
22 type = types.nullOr types.lines;
29 systemd.services.knot.serviceConfig.ExecStartPre =
30 lib.mapAttrsToList (domain: {data, ...}: ''
31 +${pkgs.coreutils}/bin/install -D -o ${users.knot.name} -g ${groups."knot".name} -m 700 \
32 ${pkgs.writeText "${domain}.zone" data} \
33 /var/lib/knot/zones/${domain}.zone
36 systemd.services.knot.postStart = lib.mkAfter ''
37 PATH="/run/current-system/sw/bin:$PATH"
38 knotc zone-freeze ${domain}.
39 while ! knotc zone-status ${domain}. +freeze | grep -q 'freeze: yes'; do sleep 1; done
40 knotc zone-flush ${domain}.
41 install -o knot -g knot -m 700 ${zone} /var/lib/knot/signed/${domain}.zone
42 knotc zone-reload ${domain}.
43 knotc zone-thaw ${domain}.
46 networking.nftables.ruleset = ''
49 meta l4proto { udp, tcp } th dport domain counter accept comment "knot: DNS"
51 set output-net-knot-ipv4 { type ipv4_addr; }
52 set output-net-knot-ipv6 { type ipv6_addr; }
54 skuid ${users.knot.name} \
55 meta l4proto { udp, tcp } th dport domain \
56 ip daddr @output-net-knot-ipv4 \
58 comment "knot: DNS notify"
59 skuid ${users.knot.name} \
60 meta l4proto { udp, tcp } th dport domain \
61 ip6 daddr @output-net-knot-ipv6 \
63 comment "knot: DNS notify"
70 # https://www.knot-dns.cz/docs/2.6/html/reference.html
73 # Listen on localhost to allow only there
74 # dynamic updates for ACME challenges.
75 listen: 127.0.0.1@5353
85 # move databases below the state directory, because they need to be writable
86 storage: /var/lib/knot/zones
87 # Input-only zone files
88 # https://www.knot-dns.cz/docs/2.8/html/operation.html#example-3
89 # prevents modification of the zonefiles, since the zonefiles are immutable
91 zonefile-load: difference
92 journal-content: changes
93 global-module: mod-rrl/default
96 journal-db: /var/lib/knot/journal
97 kasp-db: /var/lib/knot/kasp
98 timer-db: /var/lib/knot/timer
106 address: 127.0.0.1@53
108 - id: secondary_gandi
109 address: 217.70.177.40@53
111 - id: secondary_muarf
112 address: 78.192.65.63@53
115 - id: dnssec_validating_resolver
116 parent: local_resolver
120 single-type-signing: false
127 ksk-submission: dnssec_validating_resolver
130 single-type-signing: false
137 cds-cdnskey-publish: always
138 ksk-submission: dnssec_validating_resolver
141 # DOC: https://docs.gandi.net/en/domain_names/advanced_users/secondary_nameserver.html
143 address: 217.70.177.40
147 address: 78.192.65.63
150 '' + lib.concatStringsSep "\n" (lib.mapAttrsToList (domain: {conf, ...}: conf) knot.zones);