authoritative-dns: Migrate to settings

This commit is contained in:
Simon Bruder 2023-12-02 17:06:33 +01:00
parent ba843ac8c0
commit e126adc38d
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC

View file

@ -33,87 +33,100 @@ in
# so the module disables configuration checks. # so the module disables configuration checks.
"/var/lib/knot/static.conf" "/var/lib/knot/static.conf"
]; ];
# TODO migrate to settings settings = lib.mkMerge [
settingsFile = pkgs.writeText "knot.conf" ('' {
include: /var/lib/knot/static.conf server = {
listen = map (address: "${address}@53") addresses.${config.networking.hostName};
automatic-acl = true;
};
server: log = lib.singleton {
${lib.concatStringsSep "\n" (map (address: " listen: ${address}@53") addresses.${config.networking.hostName})} target = "syslog";
automatic-acl: on server = "info";
control = "warning"; # otherwise stats gets logged every scrape
zone = "info";
};
log: mod-stats = lib.singleton {
- target: syslog id = "custom";
server: info edns-presence = true;
control: warning # otherwise stats gets logged every scrape flag-presence = true;
zone: info query-size = true;
query-type = true;
reply-size = true;
};
mod-stats: remote = (lib.mapAttrsToList
- id: custom (host: hostAddresses: {
edns-presence: on id = host;
flag-presence: on address = hostAddresses;
query-size: on })
query-type: on addresses) ++ lib.optional isPrimaryHost {
reply-size: on id = "inwx";
remote:
${lib.concatStrings (lib.mapAttrsToList (host: hostAddresses: ''
- id: ${host}
address: [${lib.concatStringsSep ", " hostAddresses}]
'') addresses)}
'' + (lib.optionalString isPrimaryHost ''
# HACK: this string just continues the previous section
- id: inwx
# INWX only allows the specification of one primary DNS, # INWX only allows the specification of one primary DNS,
# which limits the IP protocol usable for zone transfers to one. # which limits the IP protocol usable for zone transfers to one.
address: [185.181.104.96] address = lib.singleton "185.181.104.96";
};
}
(lib.mkIf isPrimaryHost {
policy = lib.singleton {
id = "default";
nsec3 = true;
};
policy: template = [
- id: default {
nsec3: on id = "default";
storage = "/var/lib/knot/zones/";
template: semantic-checks = true;
- id: default
storage: /var/lib/knot/zones/
semantic-checks: on
# auto increment serial # auto increment serial
zonefile-sync: -1 zonefile-sync = -1;
zonefile-load: difference-no-serial zonefile-load = "difference-no-serial";
journal-content: all journal-content = "all";
# secondary # secondary
notify: [inwx, ${lib.concatStringsSep ", " secondaryHosts}] notify = [ "inwx" ] ++ secondaryHosts;
# dnssec # dnssec
dnssec-signing: on dnssec-signing = true;
dnssec-policy: default dnssec-policy = "default";
# stats # stats
module: mod-stats/custom module = "mod-stats/custom";
- id: nix-generated }
storage: /var/lib/knot/nix-zones/ {
semantic-checks: on id = "nix-generated";
storage = "/var/lib/knot/nix-zones/";
semantic-checks = true;
# auto increment serial # auto increment serial
zonefile-sync: -1 zonefile-sync = -1;
zonefile-load: difference-no-serial zonefile-load = "difference-no-serial";
journal-content: all journal-content = "all";
# stats # stats
module: mod-stats/custom module = "mod-stats/custom";
}
];
zone: zone = map
${lib.concatMapStrings (domain: '' (domain: {
- domain: ${domain} inherit domain;
template: nix-generated template = "nix-generated";
'') (lib.attrNames cfg.generated-zones)} })
'') + (lib.optionalString isSecondaryHost '' (lib.attrNames cfg.generated-zones);
acl: })
- id: primary_notify (lib.mkIf isSecondaryHost {
address: [${lib.concatStringsSep ", " (lib.flatten addresses.${primaryHost})}] acl = lib.singleton {
action: notify id = "primary_notify";
address = lib.flatten addresses.${primaryHost};
action = "notify";
};
template: template = lib.singleton {
- id: default id = "default";
master: [${primaryHost}] master = [ primaryHost ];
acl: [primary_notify] acl = [ "primary_notify" ];
# stats # stats
module: mod-stats/custom module = "mod-stats/custom";
'')); };
})
];
}; };
users.users.knot = { users.users.knot = {