nixos/initrd: add extraFirmwarePaths option

(cherry picked from commit 488d4316b9e1510c9b4a2eeb8d7e2cc66839a1fc)
This commit is contained in:
Jared Baur
2025-03-18 20:39:52 -07:00
parent cdc1e34423
commit ea116654aa
5 changed files with 23 additions and 2 deletions
+9
View File
@@ -19,6 +19,7 @@ let
kernel = config.system.modulesTree;
firmware = config.hardware.firmware;
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 {
default = true;
type = types.bool;
@@ -105,6 +105,7 @@ let
kernel = config.system.modulesTree;
firmware = config.hardware.firmware;
allowMissing = false;
inherit (config.boot.initrd) extraFirmwarePaths;
};
initrdBinEnv = pkgs.buildEnv {
@@ -11,6 +11,7 @@
rootModules,
kmod,
allowMissing ? false,
extraFirmwarePaths ? [ ],
}:
stdenvNoCC.mkDerivation {
@@ -25,6 +26,7 @@ stdenvNoCC.mkDerivation {
firmware
rootModules
allowMissing
extraFirmwarePaths
;
allowedReferences = [ "out" ];
}
@@ -87,6 +87,15 @@ for module in $(< ~-/closure); do
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
echo "lib/firmware/edid found, copying."
mkdir -p "$out/lib/firmware"
+2 -2
View File
@@ -709,9 +709,9 @@ with pkgs;
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 {
inherit kernel firmware rootModules allowMissing;
inherit kernel firmware rootModules allowMissing extraFirmwarePaths;
};
mkBinaryCache = callPackage ../build-support/binary-cache { };