Expose deploy-flake VM facts #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "agent/vm-facts-profiles"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Refs allod/nexus#6
Risk
R2 medium. This adds a top-level
vmFactsoutput and a reusablelib.mkVmFactsbuilder, then bumps thesecretsinput to the merged rev that exposeslib.machineHostKeysandlib.vmHostKeySecretFiles. It does not change anynixosConfigurationsbehavior.Validation
nix flake checknix eval --json .#vmFacts --apply builtins.attrNamesnix eval --json '.#vmFacts."allod-dev"' | jq -e '.ip and .username and .hostKeys.active and .hostKeySecretFile'test -r "$(nix eval --raw .#vmFacts.allod-dev.hostKeySecretFile)"! nix eval .#vmFacts.nexus! nix eval .#vmFacts.no-such-vmReview: Expose deploy-flake VM facts
Verdict: approve, ship-ready. Correctness is sound and verified end-to-end, with strong alignment to the fail-loud, one-source-of-truth, and negative-path-testing principles. The findings below are cosmetic/minor and none block.
Verified (built and evaluated, not just source-read)
vmFactsevaluates to["allod-dev","privacy-1"];nexusis correctly excluded despite having host-key, username, and age-file entries, because the filter keys off the inventorytype(the right source of truth) rather than off the secrets data.hostKeySecretFile, and thenexus/no-such-vmeval failures).nix flake check --no-buildpasses with all fournixosConfigurationsstill evaluating, confirming the "nonixosConfigurationsbehavior change" claim.vm-facts-negativeis genuinely self-validating: it asserts that each of the five mutations throws, so the negative guards are proven to fire (validation is itself validated).whileloop runs downstream of a pipe, i.e. in a subshell, so itsexit 1only terminates the subshell. I reproduced the exact pattern in arunCommandand confirmed it still fails the build: Nix builders run withset -eand thewhileis the pipeline's last stage, so the non-zero status propagates. Not a bug.Findings (minor, non-blocking)
nix flake checknow printswarning: unknown flake output 'vmFacts'on every run (exit code still 0).libis a recognized output and does not warn, whereas a bare top-levelvmFactsdoes. It can be silenced by exposing the data aslib.vmFactsinstead of (or in addition to) the top-level output, once the nexus consumption path is settled, or accepted consciously. Tracked as a follow-up.requireIprejects a nullip, butusername,hostKeySecretFile, andhostKeys.{active,staged}are only checked for key presence, not for null values (toString nullwould silently yield""). This is fine in practice because the secretscredential-inventorycheck validates those shapes upstream, but the asymmetry is worth a note.attrNamesand jqkeysproducing identically ordered arrays (jq -S .sorts object keys, not array elements). This holds for lowercase, hyphenated ASCII names but would be fragile under exotic names.Follow-up on finding 1 (the
unknown flake output 'vmFacts'warning): after checking the consumer this is by-design, not something to fix.nexus/scripts/lib/rotation-common.shreads${deploy_flake}#vmFactsand${deploy_flake}#vmFacts."<vm>"directly (attr names, then ip, username, forge_key, host keys, and host-key secret file),provision-vm-from-host.shdoes the same, and both have tests pinning that exact.#vmFactsCLI form; the nexus error text even points back here ("compose a profiles rev that provides them, see allod/nexus#6"). Moving the data underlib.vmFactswould break those consumers, and additionally exposing it there would not silence the warning while the top-level output still exists. Recommend keepingvmFactstop-level and accepting the warning consciously — no change needed, and no separate issue since there is nothing actionable. Findings 2 and 3 remain optional polish. Nothing else outstanding.