0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

nixos/initrd: add extraFirmwarePaths option (#391166)

This commit is contained in:
Will Fancher 2025-03-19 16:51:26 -04:00 committed by GitHub
commit b15e9e7d3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 23 additions and 2 deletions

View file

@ -19,6 +19,7 @@ let
kernel = config.system.modulesTree; kernel = config.system.modulesTree;
firmware = config.hardware.firmware; firmware = config.hardware.firmware;
allowMissing = false; allowMissing = false;
inherit (config.boot.initrd) extraFirmwarePaths;
}; };
@ -484,6 +485,14 @@ in
''; '';
}; };
boot.initrd.extraFirmwarePaths = mkOption {
default = [ ];
type = types.listOf types.str;
description = ''
Other firmware files (relative to `"''${config.hardware.firmware}/lib/firmware"`) to include in the final initrd we are building.
'';
};
boot.initrd.checkJournalingFS = mkOption { boot.initrd.checkJournalingFS = mkOption {
default = true; default = true;
type = types.bool; type = types.bool;

View file

@ -105,6 +105,7 @@ let
kernel = config.system.modulesTree; kernel = config.system.modulesTree;
firmware = config.hardware.firmware; firmware = config.hardware.firmware;
allowMissing = false; allowMissing = false;
inherit (config.boot.initrd) extraFirmwarePaths;
}; };
initrdBinEnv = pkgs.buildEnv { initrdBinEnv = pkgs.buildEnv {

View file

@ -11,6 +11,7 @@
rootModules, rootModules,
kmod, kmod,
allowMissing ? false, allowMissing ? false,
extraFirmwarePaths ? [ ],
}: }:
stdenvNoCC.mkDerivation { stdenvNoCC.mkDerivation {
@ -25,6 +26,7 @@ stdenvNoCC.mkDerivation {
firmware firmware
rootModules rootModules
allowMissing allowMissing
extraFirmwarePaths
; ;
allowedReferences = [ "out" ]; allowedReferences = [ "out" ];
} }

View file

@ -87,6 +87,15 @@ for module in $(< ~-/closure); do
done || : done || :
done done
for path in $extraFirmwarePaths; do
mkdir -p $(dirname $out/lib/firmware/$path)
for name in "$path" "$path.xz" "$path.zst" ""; do
if cp -v --parents --no-preserve=mode lib/firmware/$name "$out" 2>/dev/null; then
break
fi
done
done
if test -e lib/firmware/edid ; then if test -e lib/firmware/edid ; then
echo "lib/firmware/edid found, copying." echo "lib/firmware/edid found, copying."
mkdir -p "$out/lib/firmware" mkdir -p "$out/lib/firmware"

View file

@ -709,9 +709,9 @@ with pkgs;
compressFirmwareZstd = callPackage ../build-support/kernel/compress-firmware.nix { type = "zstd"; }; compressFirmwareZstd = callPackage ../build-support/kernel/compress-firmware.nix { type = "zstd"; };
makeModulesClosure = { kernel, firmware, rootModules, allowMissing ? false }: makeModulesClosure = { kernel, firmware, rootModules, allowMissing ? false, extraFirmwarePaths ? [ ] }:
callPackage ../build-support/kernel/modules-closure.nix { callPackage ../build-support/kernel/modules-closure.nix {
inherit kernel firmware rootModules allowMissing; inherit kernel firmware rootModules allowMissing extraFirmwarePaths;
}; };
mkBinaryCache = callPackage ../build-support/binary-cache { }; mkBinaryCache = callPackage ../build-support/binary-cache { };