Skip to content

feat: enable proper cross-compilation (x86_64 → aarch64) for all board modules#197

Open
gortium wants to merge 2 commits into
nvmd:developfrom
gortium:fix/cross-compile-board-modules
Open

feat: enable proper cross-compilation (x86_64 → aarch64) for all board modules#197
gortium wants to merge 2 commits into
nvmd:developfrom
gortium:fix/cross-compile-board-modules

Conversation

@gortium

@gortium gortium commented Jun 12, 2026

Copy link
Copy Markdown

Problem

When cross-compiling (x86_64 to aarch64) with nixpkgs.buildPlatform = "x86_64-linux", all board modules source kernel and firmware from:

nixos-raspberrypi.packages.${pkgs.stdenv.hostPlatform.system}.linuxPackages_rpi5

During cross-compilation, hostPlatform resolves to "aarch64-linux", which looks up packages from mkRpiPkgs:

import nixpkgs { system = "aarch64-linux"; ... }

This is always a native aarch64 import, forcing QEMU user emulation for all kernel/firmware builds.

Solution

1. modules/nixpkgs-rpi.nix — use localSystem + crossSystem instead of system alone, so the re-imported pkgs.rpi respects cross-compilation when buildPlatform != hostPlatform.

2. All board modules — use pkgs.rpi.linuxPackages_rpiX / pkgs.rpi.raspberrypifw instead of nixos-raspberrypi.packages.${system}.linuxPackages_rpiX / .raspberrypifw. The module-level pkgs.rpi is now properly cross-compiled by fix #1.

This also aligns the board modules with the project architecture: pkgs.rpi (via nixpkgs-rpi) is the module-level internal API, while nixos-raspberrypi.packages is the flake-level public API for external consumers.

Files changed

  • modules/nixpkgs-rpi.nix
  • modules/raspberry-pi-5/default.nix
  • modules/raspberry-pi-4.nix
  • modules/raspberry-pi-3.nix
  • modules/raspberry-pi-02.nix

Impact

gortium and others added 2 commits June 12, 2026 00:50
…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.
@gortium gortium changed the title fix(boards): use pkgs.rpi for kernel/firmware instead of flake-level native aarch64 packages feat: enable proper cross-compilation (x86_64 → aarch64) for all board modules Jun 13, 2026
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.

Binary cache issue

1 participant