41 lines
1.3 KiB
Nix
41 lines
1.3 KiB
Nix
|
|
# rpi-cross-overlay.nix
|
||
|
|
#
|
||
|
|
# Override pkgs.rpi to cross-compile when buildPlatform != hostPlatform.
|
||
|
|
#
|
||
|
|
# By default, nixos-raspberrypi's nixpkgs-rpi module creates pkgs.rpi via
|
||
|
|
# mkRpiPkgs which imports nixpkgs with system="aarch64-linux" — a NATIVE
|
||
|
|
# aarch64 build that requires QEMU on x86_64 builders.
|
||
|
|
#
|
||
|
|
# This module detects cross-compilation (buildPlatform != hostPlatform) and
|
||
|
|
# re-imports pkgs.rpi using localSystem (builder) + crossSystem (target) so
|
||
|
|
# that kernel, firmware, and rpi-optimized packages are genuinely cross-compiled
|
||
|
|
# with zero QEMU emulation.
|
||
|
|
#
|
||
|
|
# Once nixos-raspberrypi upstream supports buildPlatform natively in mkRpiPkgs,
|
||
|
|
# this module can be removed.
|
||
|
|
|
||
|
|
{ config, lib, pkgs, nixos-raspberrypi, ... }:
|
||
|
|
|
||
|
|
let
|
||
|
|
inherit (config.nixpkgs) buildPlatform hostPlatform;
|
||
|
|
isCross = buildPlatform.system != hostPlatform.system;
|
||
|
|
in
|
||
|
|
lib.mkIf isCross {
|
||
|
|
nixpkgs.overlays = [
|
||
|
|
(final: prev: {
|
||
|
|
rpi = import pkgs.path {
|
||
|
|
localSystem = { system = buildPlatform.system; };
|
||
|
|
crossSystem = { system = hostPlatform.system; };
|
||
|
|
overlays = with nixos-raspberrypi.overlays; [
|
||
|
|
bootloader
|
||
|
|
vendor-kernel
|
||
|
|
vendor-firmware
|
||
|
|
kernel-and-firmware
|
||
|
|
vendor-pkgs
|
||
|
|
pkgs
|
||
|
|
];
|
||
|
|
};
|
||
|
|
})
|
||
|
|
];
|
||
|
|
}
|