How to configure QEMU binfmt wrapper on a non-NixOS machine

Hi group,

I want to build aarch64 packages using a remote builder.

I have a non-aarch64 machine baseline configured as a remote builder, meaning I can just run ssh builder nix-store --version.
The machine does not have NixOS installed but nix and nix-daemon running.

I am stuck with where to add boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; equivalent as I have no configuration.nix. Do I have to set up a qemu vm with NixOS inside ?

Checkout the config section of the binfmt.nix module in NixOS. It’ll give you an idea of how to implement the same functionality on a non-NixOS system.

1 Like

Hi @ElvishJerricco, thanks for giving a good hint here, as far as I understand it, the remote builder running on arch linux I would have to install the binfmt packages provided in arch linux’ aur ?

Or do you mean implementing the config boot.* attribute in like home-manager, cause I’m using home-manager on that remote builder ?

Still lost somehow.

Edit: Found this as a further reference. If there is an alternative approach to try I’d be happy to contribute to it, especially the binfmt.nix based one for nix-only (but non-NixOS) setups.

Following NixOS on a Raspberry Pi: creating a custom SD image with OpenSSH out of the box | Roberto Frenna’s description I installed the needed binaries on my arch linux box and trying with the minimal sd-image.nix given in Robert’s article triggered a build using

nix-build '<nixpkgs/nixos>' -A --option system aarch64-linux --option sandbox false -I nixos-config=sd-image.nix

but got another error: /run/current-system/systemd/bin/systemctl is called in udev rules but is not executable or does not exist.