network/nix/pkgs/dns-slaves.nix

33 lines
752 B
Nix
Raw Normal View History

2021-05-06 17:42:26 +02:00
{ self, nixpkgs, system }:
with nixpkgs.legacyPackages.${system};
2021-06-02 23:44:02 +02:00
let
servConf = self.lib.config.site.net.serv;
masterAddrs =
[servConf.hosts4.dns] ++
map (hosts6: hosts6.dns)
(builtins.attrValues servConf.hosts6);
mastersStr =
builtins.foldl' (result: addr:
"${result} ${addr};"
) "" masterAddrs;
in
2021-05-06 17:42:26 +02:00
writeText "named.slave.conf" (
lib.concatMapStringsSep "\n" ({ name, ns, ... }: ''
zone "${name}" IN {
type slave;
2021-06-02 23:44:02 +02:00
masters {${mastersStr} };
2021-05-06 17:42:26 +02:00
file "/var/lib/bind/slave/${name}.zone";
2021-06-02 23:44:02 +02:00
allow-notify {${mastersStr} };
allow-query { all; };
2021-05-06 17:42:26 +02:00
};
'') (
# public zones only
builtins.filter ({ ns, ... }:
ns == self.lib.dns.publicNS
) self.lib.dns.localZones
)
)