Select the guest module from the inventory runtime fact #22
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/archetypes#22
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Make the VM builders compose the guest module the inventory
runtimefact selects, so a machine that declaresmicrovmactually builds as one. Every piece this needs already exists and is merged — the runtime fact, both guest modules, the host runtime — and nothing joins them, soruntimeis currently a label with no effect on what gets built.Primary goals:
libvirtcomposes the qemu guest, a machine declaringmicrovmcomposes the microvm guest, and neither is chosen by name or by default.microvmand builds a libvirt guest should become impossible, rather than the current silent outcome.Current state and specifics
flake.nix:60definessharedModules, andflake.nix:61hard-codesvm.nixosModules.qemuGuestas the first entry. BothmkDevVm(flake.nix:175) andmkPrivacyVm(flake.nix:228) build their module list from it, so every machine gets the libvirt guest regardless of what inventory says.Everything the swap needs is already exported and merged:
inventory.lib.vmRuntimesis a checked machine → runtime map. Forcing it runs inventory's fail-closed assertions, so a missing, non-string, or unknown runtime is an evaluation error in the consumer rather than a silent default.allod/vmexportsnixosModules.qemuGuestandnixosModules.microvmGuestas a matched pair, each already bundling its own upstream module.modules/qemu-guest.nixsetsallod.vm.guestRuntimes = [ "libvirt" ]andmodules/microvm-guest.nixsets[ "microvm" ], andmodules/guest-base.nixalready asserts exactly one runtime module is composed.That last point is what makes the check cheap. The built system can be asked which runtime it actually composed, so the check is a comparison between two independently derived facts — the inventory declaration and the guest module's own marker — rather than a restatement of the builder's
if.A machine on the microvm runtime is currently provisioned and running as an ordinary qemu guest with the label attached, which is the concrete symptom.
Scope
In scope: the guest-module selection in
sharedModules, and a check pairing each machine's declared runtime against its built system'sallod.vm.guestRuntimes.Out of scope, and each already tracked or delivered elsewhere: the host-side runtime and per-VM isolation; the persistent volume declarations a microvm guest needs before it can carry state; runtime-aware credential delivery; and the rotation tools' runtime dispatch, which is allod/nexus issues 21 and 22. Those consume the interface this issue makes real, so they stay blocked until a machine can actually build as a microVM.
Provisioning and lifecycle scripts are also out of scope. They still drive libvirt unconditionally, so a machine that starts building as a microVM does not thereby become deployable by the existing host scripts; that seam needs its own issue once this lands.
Validation
libvirtproduces a byte-identical system to today. This is the one that matters most — the fleet is entirely on libvirt, so the change must be a no-op for every existing machine, provable by comparing derivation paths before and after rather than by inspection.microvmcomposes the microvm guest, and its built system reportsallod.vm.guestRuntimes = [ "microvm" ].Implemented in #23. Three claims in this issue did not survive checking, recorded here so the issue text can be corrected rather than read as accurate later.
inventory.lib.vmRuntimesdoes not exist. Not onmaster, not anywhere in history, not on the unmergedagent/inventory-runtime-factbranch.allod/inventoryexportsmachines,lib.machines,lib.supportedPlatforms,lib.vmSpecsJson, andchecks. The capability this issue wanted it for is real and available by another path: readinginventory.machines.<name>.runtimeforces the full four-assertion validation chain through inventory'scheckedMachinestrip-wire, so a missing, non-string, or unknown runtime is still an evaluation error in the consumer. The implementation uses that.The scope boundary contradicts the validation criteria. This issue puts "the persistent volume declarations a microvm guest needs before it can carry state" out of scope, while requiring that a machine declaring
microvmcomposes the microvm guest and reportsallod.vm.guestRuntimes = [ "microvm" ]. ComposingmicrovmGuestwithout a/nix/var/nixvolume fails evaluation on allod/vm's contract 6a, so the second is unreachable under the first. Resolved by having the check fixture supply a placeholder volume while the builder supplies none — the selection is proven without the state milestone, and a real machine selectingmicrovmstill fails closed until contract 13 lands.The prerequisites were understated. "Every piece this needs already exists and is merged" is true of the source repos but not of
archetypes, whose lock pinnedinventoryatefe4a7c(predating the runtime fact — no machine there has the attribute) andvmat2acc559(predating the guest-module split — nomicrovmGuestto select). Two input bumps were required before any of the selection could be written. They turned out to be a clean no-op:nixpkgsanddiskoare identical at bothvmrevisions, and all three machine derivations are unchanged.One adjacent defect found in
allod/inventorywhile verifying this, not fixed in #23 since it belongs to that repo:inventory/flake.nix:37-38claims "The runtime enum's microvm branch is covered by the mutation fixtures below." It is not. The only fixture carrying"microvm"sets it onnexus, a hypervisor, andruntimeDiagnosticsnever compares hypervisor runtimes againstvalidRuntimes. Deleting"microvm"fromvalidRuntimeswould leave every inventory check green.flake.nix:306-308,flake.nix:438, andREADME.md:71-77carry the same stale claim that the public examples cover both enum values; both have beenlibvirtsince commit15ad552. Worth its own issue.