infrastructure/meta/default.nix
Tom Hubrecht 1e254d5f27
All checks were successful
build configuration / build_storage01 (push) Successful in 49s
build configuration / build_vault01 (push) Successful in 44s
build configuration / build_compute01 (push) Successful in 1m10s
build configuration / build_web02 (push) Successful in 41s
build configuration / build_web01 (push) Successful in 1m1s
feat(meta): Add dns config v0
2024-01-31 15:27:26 +01:00

62 lines
1.3 KiB
Nix

###
# Metadata for the nodes. You can add custom attributes, they are
# accessible through the specialArg meta in the config.
let
###
# Transforms data from :
# {
# zone01 = [ node01 node02 ];
# zone02 = [ node03 ];
# }
# to :
# {
# node01 = zone01;
# node02 = zone01;
# node03 = zone02;
# }
locations = builtins.foldl' (a: loc: a // loc) { } (
builtins.concatLists (
builtins.attrValues (builtins.mapAttrs (zone: builtins.map (n: { ${n} = zone; })) infra)
)
);
###
# Add computed data about the nodes :
# - zone
# - deployment tags
# - network information
mkNode =
node: attrs:
attrs
// {
zone = locations.${node};
deployment =
let
old = attrs.deployment;
in
old
// {
tags = (old.tags or [ ]) ++ [ "infra-${locations.${node}}" ];
targetHost = old.targetHost or (builtins.head network.${node}.addresses.public);
};
};
infra = import ./infrastructure.nix;
members = import ./members.nix;
network = import ./network.nix;
nodes = builtins.mapAttrs mkNode (import ./nodes.nix);
meta = {
inherit
infra
members
network
nodes
;
};
dns = args: import ./dns.nix (args // { inherit meta; });
in
meta // { inherit dns; }