From 41a7f05c5046876085af39d599aef73f7c987ca8 Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 2 Jun 2021 23:44:02 +0200 Subject: [PATCH] pkgs/dns-slaves: DRY masterAddrs --- nix/pkgs/dns-slaves.nix | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/nix/pkgs/dns-slaves.nix b/nix/pkgs/dns-slaves.nix index 9b0c906..a70e033 100644 --- a/nix/pkgs/dns-slaves.nix +++ b/nix/pkgs/dns-slaves.nix @@ -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