Watch
0
0
Fork
You've already forked hyperhive
0

nix: hand the review classifier its store leaf as an nspawn credential

The leaf's key was copied by a host unit into the container's root on
host disk. nspawn now reads the cert, key and store CA as root at
container start (--load-credential) and passes them in as system
credentials; the daemon's unit loads them by bare id, as an agent's
container does with its own leaf (nix/agent-modules/bao.nix). The copy
unit is gone. Where this host mints the leaf, the container starts after
swarm-bao-pki, since nspawn refuses a missing credential source. An
assertion refuses identity paths with whitespace, which nixos-container's
unquoted extra flags would split.
This commit is contained in:
atlas 2026-10-12 04:09:03 +02:00 • committed by mara
commit 8e33de6fb7
3 changed files with 57 additions and 56 deletions

View file

@ -311,9 +311,10 @@ let
&& withClassifier.containers ? swarm-review-classifier;
}
{
# The daemon holds its store leaf and nothing else from the host; the
# key is read per run and reaches only `claude`'s environment. Reading
# the claude path also evaluates the container's unfree allowance.
# The daemon holds its store leaf, handed in by nspawn without a copy on
# disk, and nothing else from the host; the key is read per run and
# reaches only `claude`'s environment. Reading the claude path also
# evaluates the container's unfree allowance.
name = "the review classifier loads only its store leaf and carries no API key in its unit";
ok =
let
@ -321,12 +322,19 @@ let
withClassifier.containers.swarm-review-classifier.config.systemd.services.swarm-review-classifier;
env = svc.environment;
in
lib.elem "bao-client.pem:/var/lib/swarm-review-classifier/bao-client.pem" svc.serviceConfig.LoadCredential
&& env.BAO_CLIENT_CERT == "/run/credentials/swarm-review-classifier.service/bao-client.pem"
lib.elem "review-classifier-bao-key" svc.serviceConfig.LoadCredential
&&
env.BAO_CLIENT_KEY == "/run/credentials/swarm-review-classifier.service/review-classifier-bao-key"
&& env.SWARM_REVIEW_CLASSIFIER_OIDC_CLIENT_ID == "swarm-review-classifier"
&& lib.hasSuffix "/bin/claude" env.SWARM_REVIEW_CLASSIFIER_CLAUDE
&& !(env ? ANTHROPIC_API_KEY)
&& withClassifier.systemd.services ? swarm-review-classifier-identity;
&& lib.elem "--load-credential=review-classifier-bao-key:/var/lib/swarm-bao-pki/review-classifier-key.pem" (
withClassifier.containers.swarm-review-classifier.extraFlags
)
# No host unit copies the leaf into the container's root.
&& !(lib.any (u: lib.hasInfix "nixos-containers/swarm-review-classifier" (u.script or "")) (
lib.attrValues withClassifier.systemd.services
));
}
{
# The collector reaches these routes through the gateway now, so each