Exec format error when binfmt-building

Building GitHub - pinpox/nixos-raspi4-template: Genearate NixOS images for Raspberry Pi 4 (rpi4-image.nix replaces nixos/modules/installer/sd-card/sd-image-aarch64.nix) throws an exec format error that goes away when I change boot.binfmt.emulatedSystems = [ "aarch64-linux" "armv7l-linux" ]; in my configuration.nix to just contain one entry i. e. boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; in this case, probably flakes related, but I did not find a reference yet.

Yeah, that is a drawback of binfmt when build systems are not perfect. You probably need to figure out which package is causing this exactly and then debug itself nix expression and potentially its build system. I would recommend to use another way to build the image.

Nothing about this is specific to flakes.

1 Like

Thanks, good to know for general directions, it occurs within NixOS-WSL, that is my only NixOS-machine so far.
I will definitly get back with new information when I know more.

Another finding, when I switch to use “armv7l-linux” it helped to restart systemd-binfmt to get rid of another exec format error, background here: binfmt armv7 not working on aarch64 linux on Apple M1 CPU · Issue #171297 · NixOS/nixpkgs · GitHub