diff options
-rw-r--r-- | modules/private/dns.nix | 15 | ||||
m--------- | nixops/secrets | 0 |
2 files changed, 12 insertions, 3 deletions
diff --git a/modules/private/dns.nix b/modules/private/dns.nix index 1149daf..7c59b43 100644 --- a/modules/private/dns.nix +++ b/modules/private/dns.nix | |||
@@ -2,16 +2,25 @@ | |||
2 | { | 2 | { |
3 | options.myServices.dns.enable = lib.mkEnableOption "enable DNS resolver"; | 3 | options.myServices.dns.enable = lib.mkEnableOption "enable DNS resolver"; |
4 | config = let | 4 | config = let |
5 | # taken from unstable | ||
6 | cartesianProductOfSets = attrsOfLists: with lib; | ||
7 | lib.foldl' (listOfAttrs: attrName: | ||
8 | concatMap (attrs: | ||
9 | map (listValue: attrs // { ${attrName} = listValue; }) attrsOfLists.${attrName} | ||
10 | ) listOfAttrs | ||
11 | ) [{}] (attrNames attrsOfLists); | ||
5 | cfg = config.services.bind; | 12 | cfg = config.services.bind; |
6 | keyIncludes = builtins.concatStringsSep "\n" (map (v: "include \"/var/secrets/bind/${v}.key\";") (builtins.attrNames config.myEnv.dns.keys)); | 13 | keyIncludes = builtins.concatStringsSep "\n" (map (v: "include \"/var/secrets/bind/${v}.key\";") (builtins.attrNames config.myEnv.dns.keys)); |
14 | cartProduct = lib.foldr | ||
15 | (s: servers: servers // { ${s.masters} = lib.unique ((servers.${s.masters} or []) ++ [s.keys]); }) | ||
16 | {} | ||
17 | (lib.unique (lib.concatMap (z: cartesianProductOfSets { masters = z.masters or []; keys = z.keys or []; }) config.myEnv.dns.slaveZones)); | ||
7 | toKeyList = servers: keys: builtins.concatStringsSep "\n" (map (s: '' | 18 | toKeyList = servers: keys: builtins.concatStringsSep "\n" (map (s: '' |
8 | server ${s} { | 19 | server ${s} { |
9 | keys { ${builtins.concatStringsSep ";" keys}; }; | 20 | keys { ${builtins.concatStringsSep ";" keys}; }; |
10 | }; | 21 | }; |
11 | '') servers); | 22 | '') servers); |
12 | serverIncludes = builtins.concatStringsSep "\n" (map (v: | 23 | serverIncludes = builtins.concatStringsSep "\n" (lib.mapAttrsToList (n: toKeyList (lib.flatten (builtins.attrValues config.myEnv.dns.ns."${n}"))) cartProduct); |
13 | lib.optionalString (builtins.length v.keys > 0) (toKeyList (lib.flatten (map (n: builtins.attrValues config.myEnv.dns.ns."${n}") v.masters)) v.keys) | ||
14 | ) config.myEnv.dns.slaveZones); | ||
15 | configFile = pkgs.writeText "named.conf" '' | 24 | configFile = pkgs.writeText "named.conf" '' |
16 | include "/etc/bind/rndc.key"; | 25 | include "/etc/bind/rndc.key"; |
17 | controls { | 26 | controls { |
diff --git a/nixops/secrets b/nixops/secrets | |||
Subproject 3246bc60354e06ad3777be50cec01af072bb8d9 | Subproject f5418699b19f968c232c3e6cdad79b4df1616c6 | ||