diff --git a/flake.nix b/flake.nix index 04f0b2b..8281cde 100644 --- a/flake.nix +++ b/flake.nix @@ -70,6 +70,9 @@ terraform = pkgs.opentofu; terraformCfg = terranix.lib.terranixConfiguration { inherit system; + extraArgs = { + inherit (self) nixosConfigurations; + }; modules = [ ./terraform { @@ -180,7 +183,7 @@ # Filter all nodes by the range data for this flavor. filteredNodes = lib.filterAttrs (name: node: lib.any (r: inRange node.bagel.baremetal.num r) ranges) nodes; # The enumeration from baremetal numbers to flavor-specific numbers. - indexes = lib.traceValSeq (reverseEnumerate (map (n: toString n.bagel.baremetal.num) (builtins.attrValues filteredNodes))); + indexes = reverseEnumerate (map (n: toString n.bagel.baremetal.num) (builtins.attrValues filteredNodes)); in # Build a new attrset with a new second-level index for the specific flavor. lib.mapAttrs (name: node: setFlavor indexes.${toString node.bagel.baremetal.num} node) filteredNodes; diff --git a/terraform/dnsimple.nix b/terraform/dnsimple.nix index 07d513c..530a662 100644 --- a/terraform/dnsimple.nix +++ b/terraform/dnsimple.nix @@ -1,7 +1,10 @@ -{ lib, config, ... }: +{ nixosConfigurations, lib, config, ... }: let - inherit (lib) mkEnableOption mkIf tf genList; + inherit (lib) mkEnableOption mkIf tf genList filterAttrs; cfg = config.bagel.dnsimple; + filterBaremetalNodes = submodule: nodes: filterAttrs (name: node: node.config.bagel.baremetal.enable && node.config.bagel.baremetal.${submodule}.enable) nodes; + builderNodes = builtins.attrValues (filterBaremetalNodes "builders" nixosConfigurations); + storageNodes = builtins.attrValues (filterBaremetalNodes "storage" nixosConfigurations); in { options.bagel.dnsimple = { @@ -127,7 +130,9 @@ in (dualProxyRecords "build-coord.wob01.infra" 300 "AAAA" "2a01:584:11::1:11") # TODO: do not hardcode, just reuse the Colmena hive module outputs to generate all the required details. ] - ++ (map (index: record "builder-${toString index}.wob01.infra" 300 "AAAA" "2a01:584:11::1:${toString index}") (genList lib.id 11)) + ++ (map (index: record "bm-${toString index}.wob01.infra" 300 "AAAA" "2a01:584:11::1:${toString index}") (genList lib.id 11)) + ++ (map (node: record "builder-${toString node.config.bagel.baremetal.builders.num}.wob01.infra" 300 "CNAME" "bm-${toString node.config.bagel.baremetal.num}") builderNodes) + ++ (map (node: record "storage-${toString node.config.bagel.baremetal.storage.num}.wob01.infra" 300 "CNAME" "bm-${toString node.config.bagel.baremetal.num}") storageNodes) ++ ( let # FIXME: figure out a way to poke `config.services.s3-revproxy` and