diff options
author | tv <tv@krebsco.de> | 2022-08-15 01:43:57 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2022-08-15 01:45:29 +0200 |
commit | 31b30c5f22757da774c1cd4d409696138e6dca6b (patch) | |
tree | e5c63478093c9206d0c66397ea89f24a92ac34cf | |
parent | a78ae459283a05c47f023be1cfa8208e4da855a4 (diff) |
zones: make zonefiles available as packages
-rw-r--r-- | krebs/3modules/zones.nix | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/krebs/3modules/zones.nix b/krebs/3modules/zones.nix index eb1351866..b9b69e993 100644 --- a/krebs/3modules/zones.nix +++ b/krebs/3modules/zones.nix @@ -1,22 +1,36 @@ with import <stockholm/lib>; -{ config, ... }: { +{ config, pkgs, ... }: { config = { - # Implements environment.etc."zones/<zone-name>" - environment.etc = let - stripEmptyLines = s: (concatStringsSep "\n" - (remove "\n" (remove "" (splitString "\n" s)))) + "\n"; - all-zones = foldAttrs (sum: current: sum + "\n" +current ) "" - ([config.krebs.zone-head-config] ++ combined-hosts); - combined-hosts = - mapAttrsToList (name: getAttr "extraZones") config.krebs.hosts; - in + environment.etc = mapAttrs' - (name: value: { + (name: pkg: { name = "zones/${name}"; - value.text = stripEmptyLines value; + value.source = pkg; }) - all-zones; + pkgs.krebs.zones; + + nixpkgs.overlays = [ + # Explicit zones generated from config.krebs.hosts.*.extraZones + (self: super: let + stripEmptyLines = s: (concatStringsSep "\n" + (remove "\n" (remove "" (splitString "\n" s)))) + "\n"; + all-zones = foldAttrs (sum: current: sum + "\n" + current) "" + ([config.krebs.zone-head-config] ++ combined-hosts); + combined-hosts = + mapAttrsToList (name: getAttr "extraZones") config.krebs.hosts; + in { + krebs = super.krebs or {} // { + zones = super.krebs.zones or {} // + mapAttrs' + (name: value: { + name = name; + value = self.writeText "${name}.zone" (stripEmptyLines value); + }) + all-zones; + }; + }) + ]; }; } |