# Glue: point the swarm-services certificate unit at the bao leaf minted for # it. # # ONE PAIRING PER FILE — the services-issuer principal ← bao, and nothing # else. Deleting this leaves a hive that takes an operator-provided path to # that credential, which is what any deployment not minting its own already # does. # # ⚠️ The minting is NOT here. ./glue-bao-tls.nix holds the CA and signs the # leaf, because the thing that owns a private key owns issuing from it. What # belongs here is the pairing: which paths `swarm-services-cert` reads. # # ⚠️ Gated on the leaf existing, not on the store running here — the same rule # ./glue-controller-bao-identity.nix states, and it matters more for this # principal than for any of its siblings: every hive in a swarm serves the # swarm's service names and therefore needs this certificate, while exactly # one of them hosts the store. # # Everything is `mkDefault`. An operator naming their own paths wins. { lib, config, ... }: let hyperhiveCfg = config.services.hyperhive; deployCfg = hyperhiveCfg.deploy; baoDeploy = deployCfg.bao; # Where ./glue-bao-tls.nix puts the leaves, derived from the reader's own # path rather than repeating that file's directory literal: an operator who # moves the PKI moves both, and the two cannot drift apart. haveMintedPki = baoDeploy.clientCertFile != null; pkiDir = if haveMintedPki then builtins.dirOf baoDeploy.clientCertFile else null; in { config = lib.mkIf (hyperhiveCfg.enable && haveMintedPki) { services.hyperhive.deploy.hive-controller.tls = { baoClientCertFile = lib.mkDefault "${pkiDir}/services-issuer.pem"; baoClientKeyFile = lib.mkDefault "${pkiDir}/services-issuer-key.pem"; }; }; }