flake: move hostRegistry to lib

This commit is contained in:
Sandro - 2023-04-11 00:24:56 +02:00
parent 1bf9c651f5
commit 0a6bf04fd2
Signed by: sandro
GPG Key ID: 3AF5A43A3EECC2E5
2 changed files with 26 additions and 20 deletions

View File

@ -223,27 +223,8 @@
let
inherit (nixos) lib;
extractZwHosts = { hosts4, hosts6, ... }:
lib.recursiveUpdate (
builtins.foldl' (result: name:
lib.recursiveUpdate result {
"${name}".ip4 = hosts4."${name}";
}
) {} (builtins.attrNames hosts4)
) (
builtins.foldl' (result: ctx:
builtins.foldl' (result: name:
lib.recursiveUpdate result {
"${name}".ip6 = hosts6."${ctx}"."${name}";
}
) result (builtins.attrNames hosts6."${ctx}")
) {} (builtins.attrNames hosts6)
);
inherit (import ./lib/network.nix { inherit lib zentralwerk; }) hostRegistry;
hostRegistry =
builtins.foldl' (result: net:
lib.recursiveUpdate result (extractZwHosts zentralwerk.lib.config.site.net."${net}")
) {} [ "core" "cluster" "c3d2" "serv" "flpk" "pub" ];
overlayList = [
self.overlays

25
lib/network.nix Normal file
View File

@ -0,0 +1,25 @@
{ lib, zentralwerk }:
rec {
extractZwHosts = { hosts4, hosts6, ... }:
lib.recursiveUpdate (
builtins.foldl' (result: name:
lib.recursiveUpdate result {
"${name}".ip4 = hosts4."${name}";
}
) {} (builtins.attrNames hosts4)
) (
builtins.foldl' (result: ctx:
builtins.foldl' (result: name:
lib.recursiveUpdate result {
"${name}".ip6 = hosts6."${ctx}"."${name}";
}
) result (builtins.attrNames hosts6."${ctx}")
) {} (builtins.attrNames hosts6)
);
hostRegistry =
builtins.foldl' (result: net:
lib.recursiveUpdate result (extractZwHosts zentralwerk.lib.config.site.net."${net}")
) {} [ "core" "cluster" "c3d2" "serv" "flpk" "pub" ];
}