pkgs/dns-slaves: DRY masterAddrs

This commit is contained in:
Astro 2021-06-02 23:44:02 +02:00
parent ee0c996ddc
commit 41a7f05c50
1 changed files with 14 additions and 10 deletions

View File

@ -2,21 +2,25 @@
with nixpkgs.legacyPackages.${system};
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
writeText "named.slave.conf" (
lib.concatMapStringsSep "\n" ({ name, ns, ... }: ''
zone "${name}" IN {
type slave;
masters {
2a00:8180:2c00:282::2;
fd23:42:c3d2:582:2::2;
172.20.73.2;
};
masters {${mastersStr} };
file "/var/lib/bind/slave/${name}.zone";
allow-notify {
2a00:8180:2c00:282::2;
fd23:42:c3d2:582:2::2;
172.20.73.2;
};
allow-notify {${mastersStr} };
};
'') (
# public zones only