Skip to content

Add cross-compilation for installer images (small, targeted change)#192

Open
randomizedcoder wants to merge 1 commit into
nvmd:developfrom
randomizedcoder:feat/cross-compile-installer-images
Open

Add cross-compilation for installer images (small, targeted change)#192
randomizedcoder wants to merge 1 commit into
nvmd:developfrom
randomizedcoder:feat/cross-compile-installer-images

Conversation

@randomizedcoder

@randomizedcoder randomizedcoder commented Jun 7, 2026

Copy link
Copy Markdown

G'day @nvmd! 👋

This is a much smaller, more targeted follow-up to #163.

That PR was large and bundled the cross-compilation work together with a big kernel/firmware refactor. I understand that is a lot to review at once. So this PR does only one thing: it adds cross-compilation for the installer SD images. This is the main feature we want and need — building the aarch64 images on an x86_64 machine without binfmt/QEMU emulation.

It is built on top of the current develop, so no refactor is included.

What this PR does

  • flake: add installerImagesCross.{rpi02,rpi3,rpi4,rpi5} outputs and matching rpiN-installer-cross nixosConfigurations. They build on x86_64-linux and target aarch64-linux.
  • flake: mkNixOSRPiInstaller now takes a buildPlatform argument. When it is set, the builder sets nixpkgs.buildPlatform, which turns on cross-compilation.
  • nixpkgs-rpi: pkgs.rpi now keeps the build/host platform split. Before, it always used the host system, so it was built natively and needed emulation. Now it is cross-compiled too when build != host.
  • The existing native installerImages.* outputs do not change.
  • README: add a "Quick start" section, and document the cross build commands.

How to build

Native (on an ARM machine), same as before:

nix build .#installerImages.rpi5    # or .rpi4

Cross (on x86_64, no emulation), new:

nix build .#installerImagesCross.rpi5    # or .rpi4

Testing

Cross-built the rpi4 and rpi5 installer images on x86_64-linux with no emulation. The build compiles its own aarch64-unknown-linux-gnu toolchain, which confirms it is really cross-compiling.

Note: cross-compiled artifacts are not in the binary cache, so the first build compiles the kernel and many packages from source.

If you would prefer a different name for the outputs, or a different way to turn on cross-compilation, happy to change it. 🙂

Thanks again for the great repo, and for all the recent improvements — it is much appreciated!

🤖 Generated with Claude Code

…ation)

Before this, building the installer images on a non-ARM machine (like
x86_64) needed binfmt/QEMU emulation, because the images are aarch64.
This adds cross-compilation, so you can build them on x86_64 directly.

• flake: add `installerImagesCross.{rpi02,rpi3,rpi4,rpi5}` outputs and
  matching `rpiN-installer-cross` nixosConfigurations. They build on
  x86_64-linux and target aarch64.
• flake: `mkNixOSRPiInstaller` now takes a `buildPlatform` argument.
  When set, it sets `nixpkgs.buildPlatform` to turn on cross-compilation.
• nixpkgs-rpi: `pkgs.rpi` now keeps the build/host platform split. Before
  it always used the host system, so it was built natively and needed
  emulation. Now it is cross-compiled too when build != host.
• The native `installerImages.*` outputs do not change.
• README: add a "Quick start" section and document the cross build commands.

Tested: cross-built rpi4 and rpi5 images on x86_64-linux with no
emulation.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant