feat: enable proper cross-compilation (x86_64 → aarch64) for all board modules#197
Open
gortium wants to merge 2 commits into
Open
feat: enable proper cross-compilation (x86_64 → aarch64) for all board modules#197gortium wants to merge 2 commits into
gortium wants to merge 2 commits into
Conversation
…native aarch64 packages When cross-compiling (buildPlatform != hostPlatform), board modules source kernel and firmware from nixos-raspberrypi.packages.$system which uses mkRpiPkgs — a native import nixpkgs with system only. This forces QEMU user emulation for all kernel/firmware builds. Fix two things: 1. modules/nixpkgs-rpi.nix: use localSystem + crossSystem so the re-imported pkgs.rpi respects cross-compilation 2. Board modules: use pkgs.rpi.linuxPackages_rpiX and pkgs.rpi.raspberrypifw instead of the flake-level native packages Affects rpi02, rpi3, rpi4, and rpi5 boards.
2 tasks
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.
Problem
When cross-compiling (x86_64 to aarch64) with
nixpkgs.buildPlatform = "x86_64-linux", all board modules source kernel and firmware from:During cross-compilation,
hostPlatformresolves to"aarch64-linux", which looks up packages frommkRpiPkgs:This is always a native aarch64 import, forcing QEMU user emulation for all kernel/firmware builds.
Solution
1. modules/nixpkgs-rpi.nix — use
localSystem+crossSysteminstead ofsystemalone, so the re-importedpkgs.rpirespects cross-compilation whenbuildPlatform != hostPlatform.2. All board modules — use
pkgs.rpi.linuxPackages_rpiX/pkgs.rpi.raspberrypifwinstead ofnixos-raspberrypi.packages.${system}.linuxPackages_rpiX/.raspberrypifw. The module-levelpkgs.rpiis now properly cross-compiled by fix #1.This also aligns the board modules with the project architecture:
pkgs.rpi(vianixpkgs-rpi) is the module-level internal API, whilenixos-raspberrypi.packagesis the flake-level public API for external consumers.Files changed
Impact
aarch64-unknown-linux-gnutoolchain