Add cross-compilation for installer images (small, targeted change)#192
Open
randomizedcoder wants to merge 1 commit into
Open
Add cross-compilation for installer images (small, targeted change)#192randomizedcoder wants to merge 1 commit into
randomizedcoder wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
installerImagesCross.{rpi02,rpi3,rpi4,rpi5}outputs and matchingrpiN-installer-crossnixosConfigurations. They build onx86_64-linuxand targetaarch64-linux.mkNixOSRPiInstallernow takes abuildPlatformargument. When it is set, the builder setsnixpkgs.buildPlatform, which turns on cross-compilation.pkgs.rpinow 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.installerImages.*outputs do not change.How to build
Native (on an ARM machine), same as before:
nix build .#installerImages.rpi5 # or .rpi4Cross (on x86_64, no emulation), new:
nix build .#installerImagesCross.rpi5 # or .rpi4Testing
Cross-built the rpi4 and rpi5 installer images on
x86_64-linuxwith no emulation. The build compiles its ownaarch64-unknown-linux-gnutoolchain, 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