Cross-compiling 'hello' to raspberryPi



I tried

$nix-build '<nixpkgs>' -A pkgsCross.raspberryPi.hello

and, because I’ve enabled flakes:

$ nix build -f channel:nixpkgs-unstable pkgsCross.raspberryPi.hello

and they both failed with “exec format error”, indicating that something is trying to run cross-compiled binaries on the host system. Here’s a full build log: cross-compile hello build log · GitHub.

I’m puzzled because this seems like a very basic cross-compilation task, so there’s possibly something fundamentally wrong with my setup. Everything not related to pkgsCross seems to work as expected.

I’m on NixOS 22.11, in a aarch-linux UTM virtual machine running on macOS M1.


It seems to be in order when cross compiling from x86_64-linux:

$ nixos-version
22.11.2759.7076110064c (Raccoon)
$ nix build -f '<nixpkgs>' pkgsCross.raspberryPi.hello
$ qemu-arm result/bin/hello 
Hello, world!

I just upgraded to latest:

22.11.20230306.47c0034 (Raccoon)

And tried again. I got a similar build error.

Possibly addressed by lib/systems/parse: stop considering armv8a able to execute armv7l by Atemu · Pull Request #211950 · NixOS/nixpkgs · GitHub

That seems very relevant, thank you! I’ll link to it in my bug report,

I can confirm this PR fixes the issue. Thank you!