diff --git a/flake.nix b/flake.nix index c1a5a3a8..8df2c96c 100644 --- a/flake.nix +++ b/flake.nix @@ -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 diff --git a/lib/network.nix b/lib/network.nix new file mode 100644 index 00000000..7cab5988 --- /dev/null +++ b/lib/network.nix @@ -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" ]; +}