Remove hardcoded CPU architecture values #1
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/vm#1
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?
User story: So that I can run the VM framework on supported CPU architectures, shared modules should derive platform and virtualization settings instead of assuming one architecture family.
Part of the "Profiles & VM archetypes" arc.
The
vmframework hardcodesx86_64-linux(and Intel-specific KVM) in severalplaces. This blocks the
aarch64-linuxhost support the framework otherwiseadvertises, and bakes CPU assumptions into shared modules. These should be
parameterized so the framework evaluates and builds for any supported system.
Hardcoded values
flake.nix:25—apps.x86_64-linux.agenixpins the app output to a single system.flake.nix:27—program = "${agenix.packages.x86_64-linux.agenix}/bin/agenix"pins the package system.modules/qemu-guest.nix:18—nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"bakes an x86_64 default for the guest platform.modules/qemu-guest.nix:16—boot.kernelModules = [ "kvm-intel" ]assumes an Intel x86 host (AMD needskvm-amd;aarch64needs neither).Suggested approach
agenixapp over supported systems (e.g.flake-utils.lib.eachDefaultSystem, orgenAttrsover a systems list) instead of hardcodingx86_64-linux.nixpkgs.hostPlatformfrom consumer/inventory data (the machine'splatform) rather than a baked default.no-hardcoded-archflake check (asnexushas) that greps framework modules for literal Nix system strings, to prevent regressions.README.mdreferencesx86_64-linuxas well and should follow once the code is parameterized.Additional scan detail for the inventory-owned machine platform rule:
Why it matters
Machine platform facts are selected by inventory and passed through the deploy/archetypes builder into
nixosSystem { system = platform; }. A shared VM framework module should not install its own machine platform default, because that duplicates the same fact in a lower layer and can silently override or mask inventory-driven platform selection.The agenix app key is a related host-tool surface rather than necessarily the primary machine-platform violation. A future hardcoded-architecture guard should decide how to handle host-tool app keys explicitly: generate them from supported tool platforms, allowlist them, or document the exception.
Exact grep hits
Acceptance
modules/qemu-guest.nixno longer setsnixpkgs.hostPlatformto a machine platform default.platformtonixosSystem { system = platform; }.Investigated this while reviewing the VM isolation model. Three findings sharpen the issue, and one changes the suggested approach.
The
hostPlatformdefault does override inventory, not just "can"The existing comment says the module default "can silently override or mask inventory-driven platform selection." It does, on every dev and privacy VM, unconditionally. Measured against the pinned nixpkgs
b6018f87da91d19d0ab4cf979885689b469cdd41with inventory declaringaarch64-linux:pkgs.stdenv.hostPlatform.systemmodules/qemu-guest.nix:18presentx86_64-linuxaarch64-linuxplatformpassed explicitlyaarch64-linuxNo warnings, no failed assertions in the wrong case. The mechanism:
nixos/modules/misc/nixpkgs.nix:74branches onopt.hostPlatform.isDefined, which is true for a definition at any priority includinglib.mkDefault, and that branch ignoresnixpkgs.systementirely. So the builder'snixosSystem { system = platform; }inallod/archetypes(flake.nix:173,:219) is silently discarded. nixpkgs' own platform-conflict assertion (misc/nixpkgs.nix:395) does not fire because it keys offnixpkgs.localSystem's priority, andnixos/lib/eval-config.nix:55definesnixpkgs.system, neverlocalSystem.This is a principle 11 violation specifically — the two facts disagree inside one configuration and nothing says so.
kvm-intelshould be deleted, not made vendor-awareThe suggested approach offers "make the KVM kernel module platform/vendor-aware, or move it to the consumer's hardware configuration." Deleting it outright is better, for three reasons:
kvm_intelis the host-side VT-x backend; inside a guest it only provides/dev/kvmunder nested virt. No guest module sets anyvirtualisation.*option, no guest package set contains qemu/libvirt/podman, andnexus/scripts/new-vm:120-129passes no--cpu, so nested virt is never requested. The only correct occurrence in the tree isallod/inventoryflake.nix:48, insidemachines.nexus.hardware— a bare-metal fact in the fact-owning repo, describing the host that actually runs libvirtd.boot.kernelModulesfailures are swallowed:nixos/modules/system/boot/kernel.nix:455setsSuccessExitStatus = "0 1"onsystemd-modules-loadwith the comment that these are "nice to have but not required." There is no build-time existence check either. So the line has zero observable effect today and would have zero effect on an AMD or aarch64 host — it is noise, not a live bug.hostPlatformis a platform fact inventory already owns and asserts. CPU vendor is not — inventory carries no such field, and adding one to feed a module with no consumer is duplication in the wrong direction.Deleting does not remove
kvm_intel.kofrom the system;boot.kernelModulesonly controls boot-time autoload, and the module tree is unaffected. If nested virt ever becomes a real requirement it can be added then, driven by an actual use case.Nothing anywhere would catch a regression
allod/vmexposes nochecksoutput at all (flake.nix:24-34isapps,nixosModules,homeModules), which is what let the hardcode in. On the consumer side, none of the eight checks underallod/archetypesflake.nix:370reads a platform, and neither do the two inallod/inventory—vmSpecsJsondeliberately omitsplatform(inventory/flake.nix:94-97), so it is invisible tovm-specs-jsonand to the provisioning scripts.The
no-hardcoded-archcheck suggested above already exists one repo over, atnexus/flake.nix:77-90, and would have caughtmodules/qemu-guest.nix:18on day one. Worth lifting more or less verbatim.Fix shape and sequencing
modules/qemu-guest.nix:1should takeplatformas a required argument and setnixpkgs.hostPlatform = platformwith nolib.mkDefault, so a second definition is a module-system conflict rather than a silent shadow, and omitting the argument is an eval error naming the missing fact. The precedent is already in the file:usernameis requested at:1and supplied viaspecialArgs.flake.nix:30needs no change —specialArgsreach imported modules through the{ ... }:wrapper.The consumer half is now tracked as issue
allod/archetypes#14: passingplatforminspecialArgsatflake.nix:174and:220, plus a coherence check comparing the built system tomachines.<name>.platformwith a mutation case.archetypespinsvmby flake input, so the order is (1)allod/archetypes#14specialArgs, inert alone; (2) this issue; (3) the input bump plus the check. Reversing (1) and (2) breaks evaluation at the bump.Note that
mkHypervisor(allod/archetypesflake.nix:233) does not import this module and already derives its platform correctly — only dev and privacy VMs are affected.Two adjacent cleanups in the same file
modules/qemu-guest.nix:15listsvirtio_pciandvirtio_blk, both already supplied by the importedmodulesPath + "/profiles/qemu-guest.nix"(nixpkgsnixos/modules/profiles/qemu-guest.nix:8,11). The remaining three are arch-generic and already fail loud viaboot.initrd.allowMissingModules = false, so this is a dedupe, not a portability fix.modules/qemu-guest.nix:66hardcodessystem.stateVersion = "25.11"in a framework module. That is a per-machine install-time fact, so a machine provisioned after the next release silently inherits25.11. Not architecture, and not for this issue — raising it separately if it is worth tracking.What this does not fix
Making the platform correct and loud does not make
aarch64provisionable.nexus/scripts/new-vm:120-129passes no--archand cannot seeplatformat all,allod/archetypesflake.nix:51-52still forbids a heterogeneous fleet, andprovision-vm-from-hostandrebuild-vm-from-hostbuild the closure on nexus, so a genuinely non-native machine would need binfmt or a remote builder.nexus/README.md:45-49already describes aarch64 as exposed-but-unvalidated; that stays true after this lands.