Pass inventory platform into the VM builders and check the built system matches #14
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
allod/archetypes#14
Loading…
Add table
Add a link
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?
Pass each machine's inventory
platforminto the VM builders'specialArgs, and add a check that the built system matches the inventory fact, so a platform mismatch fails loudly instead of silently building the wrong architecture.Primary goals:
mkDevVmandmkPrivacyVmboth bindplatformand then drop it, so the guest module inallod/vmhas no way to derive it.machines.<name>.platform; today the two disagree with zero diagnostics.vm-facts-negativecheck.allod/vm#1makes the argument required, becausearchetypespinsvmas a flake input.Current state
mkDevVmbindsplatform = machines.${name}.platform(flake.nix:168) and honors it fornixpkgs-unstable(:169) and fornixosSystem { system = platform; }(:173), but itsspecialArgs(:174) passes onlyhostPublicKeys,identity,tokenFile,secrets, andusername.mkPrivacyVmhas the same shape:platformbound at:214,specialArgsat:220passing onlyhostPublicKeysandusername.The
system = platformargument does not survive contact with the guest module.nixpkgs.hostPlatformtakes precedence whenever it is defined at any priority, andallod/vm'smodules/qemu-guest.nix:18defines it aslib.mkDefault "x86_64-linux", which every dev and privacy VM imports throughsharedModules(flake.nix:60). Evaluated against the pinned nixpkgsb6018f87da91d19d0ab4cf979885689b469cdd41, with inventory declaringaarch64-linux:pkgs.stdenv.hostPlatform.systemmkDefault "x86_64-linux"presentx86_64-linuxaarch64-linuxplatformpassed explicitlyaarch64-linuxThe wrong case emits no warnings and no failed assertions. nixpkgs' own platform-conflict assertion (
nixos/modules/misc/nixpkgs.nix:395) is vacuous here: it keys offnixpkgs.localSystem's priority, andnixos/lib/eval-config.nix:55definesnixpkgs.system, neverlocalSystem.mkHypervisor(flake.nix:233) does not includesharedModulesand never imports the guest module, so it already derives its platform correctly. Only the dev and privacy builders are affected.Because
flake.nix:169does honor the fact fornixpkgs-unstable, a non-x86_64 machine would also get an arch-mismatched home closure —claude-code,codex, andpi-coding-agentbuilt for the inventory platform inside a system built forx86_64-linux.No check catches it
checks(flake.nix:370) is keyed bygenAttrs supportedPlatformsbut never compares the inventory fact against the built system. None ofcredential-profiles(:371),vm-facts-coherence(:671),vm-facts-negative(:727),netrc-activation(:784),profile-definition-contracts(:804),composed-layer-smoke(:857),pi-integration(:862), oragent-vm-status(:891) reads a platform.platformis absent fromvmFacts(nix/vm-facts.nix:82-87) and fromvmSpecsJsoninallod/inventory(flake.nix:94-97), so neither the facts layer nor the provisioning scripts can see it.The nearest loud thing is the installer single-platform assertion (
flake.nix:51-52), which fires only for a heterogeneous fleet, only whennixosConfigurations.installeris forced —nix flake checkforces it,nixos-rebuild --flake .#<machine>andnixos-anywheredo not — and reports an unrelated message. A homogeneous non-x86_64 fleet gets no diagnostic at all.Scope
In scope: adding
platformtospecialArgsatflake.nix:174and:220; a per-machine coherence check asserting that the builtpkgs.stdenv.hostPlatform.systemequalsmachines.<name>.platform, with a mutation case proving the check fails on sabotaged input; and thevminput bump onceallod/vm#1lands.Handled by issue
allod/vm#1: requiring the argument inmodules/qemu-guest.nix, removingboot.kernelModules = [ "kvm-intel" ], theapps.x86_64-linux.agenixkey, and ano-hardcoded-archguard in that repo.Out of scope, each its own follow-up if wanted: relaxing the single-platform installer assertion for heterogeneous fleets; carrying
platformintovm-specs.jsonandnew-vm, which passes no--archand so cannot provision a non-native guest; and the binfmt or remote-builder support a genuinely non-native machine needs, sinceprovision-vm-from-hostandrebuild-vm-from-hostbuild the closure on nexus. This issue makes the platform correct and loud; it does not makeaarch64provisionable.Sequencing
archetypespinsvmby flake input (flake.nix:5), so the argument must be passed before it is required: (1) thespecialArgschange here, inert on its own since unusedspecialArgsare harmless; (2) issueallod/vm#1; (3) thevminput bump plus the coherence check and its mutation case. Reversing (1) and (2) breaks evaluation at the input bump.Part of the same arc as issue
allod/vm#1.