raspberry-pi/common: fix firmware install when cross-compiling

This commit is contained in:
Jamie Magee 2026-07-12 23:02:21 -07:00
parent 8efb4337e8
commit f185edb4e9

View file

@ -24,9 +24,11 @@ let
# install-rpi-firmware <target-dir>
# Idempotent: copies via temp file + rename, and prunes stale DTBs/overlays.
installScript = pkgs.writeShellApplication {
mkInstallScript =
scriptPkgs:
scriptPkgs.writeShellApplication {
name = "install-rpi-firmware";
runtimeInputs = [ pkgs.coreutils ];
runtimeInputs = [ scriptPkgs.coreutils ];
text = ''
target="$1"
shopt -s nullglob
@ -99,6 +101,10 @@ let
echo "rpi-firmware: done ($target)"
'';
};
# Target tools for activation, build tools for images.
installScript = mkInstallScript pkgs;
imageInstallScript = mkInstallScript pkgs.buildPackages;
in
{
options.hardware.raspberry-pi.firmware = {
@ -189,7 +195,7 @@ in
# sd-image module is imported. mkForce so we override (not merge with)
# sd-image-aarch64.nix, which also sets this and would clobber config.txt.
(lib.optionalAttrs (options ? sdImage) {
sdImage.populateFirmwareCommands = lib.mkForce "${lib.getExe installScript} ./firmware\n";
sdImage.populateFirmwareCommands = lib.mkForce "${lib.getExe imageInstallScript} ./firmware\n";
})
(lib.mkIf cfg.enable {
system.activationScripts.raspberry-pi-firmware = lib.stringAfter [ "specialfs" ] ''