zones: make zonefiles available as packages
This commit is contained in:
parent
a78ae45928
commit
31b30c5f22
@ -1,22 +1,36 @@
|
|||||||
with import <stockholm/lib>;
|
with import <stockholm/lib>;
|
||||||
{ config, ... }: {
|
{ config, pkgs, ... }: {
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
# Implements environment.etc."zones/<zone-name>"
|
environment.etc =
|
||||||
environment.etc = let
|
mapAttrs'
|
||||||
|
(name: pkg: {
|
||||||
|
name = "zones/${name}";
|
||||||
|
value.source = pkg;
|
||||||
|
})
|
||||||
|
pkgs.krebs.zones;
|
||||||
|
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
# Explicit zones generated from config.krebs.hosts.*.extraZones
|
||||||
|
(self: super: let
|
||||||
stripEmptyLines = s: (concatStringsSep "\n"
|
stripEmptyLines = s: (concatStringsSep "\n"
|
||||||
(remove "\n" (remove "" (splitString "\n" s)))) + "\n";
|
(remove "\n" (remove "" (splitString "\n" s)))) + "\n";
|
||||||
all-zones = foldAttrs (sum: current: sum + "\n" + current) ""
|
all-zones = foldAttrs (sum: current: sum + "\n" + current) ""
|
||||||
([config.krebs.zone-head-config] ++ combined-hosts);
|
([config.krebs.zone-head-config] ++ combined-hosts);
|
||||||
combined-hosts =
|
combined-hosts =
|
||||||
mapAttrsToList (name: getAttr "extraZones") config.krebs.hosts;
|
mapAttrsToList (name: getAttr "extraZones") config.krebs.hosts;
|
||||||
in
|
in {
|
||||||
|
krebs = super.krebs or {} // {
|
||||||
|
zones = super.krebs.zones or {} //
|
||||||
mapAttrs'
|
mapAttrs'
|
||||||
(name: value: {
|
(name: value: {
|
||||||
name = "zones/${name}";
|
name = name;
|
||||||
value.text = stripEmptyLines value;
|
value = self.writeText "${name}.zone" (stripEmptyLines value);
|
||||||
})
|
})
|
||||||
all-zones;
|
all-zones;
|
||||||
};
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user