Hello!
I have an x86-64 laptop running nixos and I’m planning to use it to develop config for some of my other hosts (an x86-64 home server and a raspberry pi attached to my 3d printer).
For x86-64 configs, I can easily sanity check them with nixos-rebuild build-vm
but that doesn’t work for the aarch64 config:
error: assertion '(system != (pkgs).stdenv.hostPlatform.system)' failed
at /nix/store/myf9yi8lam7z19q8dydwzk8vyjxs360j-source/nixos/modules/system/boot/binfmt.nix:354:9:
353| system:
354| assert system != pkgs.stdenv.hostPlatform.system;
| ^
355| {
I assume I’m just missing some magic switch to allow my laptop to cross-build aarch64 packages, but i’m struggling to find any documentation about this.
Any help is hugely appreciated!
No, unless there has been some recent work on this, it’s not supported. The script that runs the VM uses qemu-kvm under the hood: as there is no emulation, the gust arch must equal the host arch.
It’s probably not to difficult to use the cross-compilation machinery of Nixpkgs to implement it, but it has never been done.
If you just want to test the system configuration, a VM with the host architecture is probably good enough, just uncomment the device specific parts, or use virtualisatin.vmVariant. Even if you were able to build a generic aarch64 VM, it’s likely not going to be able to boot the raspberry pi SD image.
I tested this a few years ago, and while Qemu could nominally emulate the raspberry pi 1 hardware, I never managed to run u-boot on it.
Isn’t it possible to generate a UEFI VM image for the build architecture? Not that it matters too much unless you’re trying to test some architecture-specific stuff.