mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 07:53:19 +00:00
Merge pull request #172820 from alyssais/compressed-firmware
Compressed firmware
This commit is contained in:
commit
fb222e0086
@ -83,7 +83,6 @@ in {
|
||||
broadcom-bt-firmware
|
||||
b43Firmware_5_1_138
|
||||
b43Firmware_6_30_163_46
|
||||
b43FirmwareCutter
|
||||
xow_dongle-firmware
|
||||
] ++ optionals pkgs.stdenv.hostPlatform.isx86 [
|
||||
facetimehd-calibration
|
||||
|
@ -171,6 +171,11 @@ let
|
||||
mv etc/udev/hwdb.bin $out
|
||||
'';
|
||||
|
||||
compressFirmware = if config.boot.kernelPackages.kernelAtLeast "5.3" then
|
||||
pkgs.compressFirmwareXz
|
||||
else
|
||||
id;
|
||||
|
||||
# Udev has a 512-character limit for ENV{PATH}, so create a symlink
|
||||
# tree to work around this.
|
||||
udevPath = pkgs.buildEnv {
|
||||
@ -267,7 +272,7 @@ in
|
||||
'';
|
||||
apply = list: pkgs.buildEnv {
|
||||
name = "firmware";
|
||||
paths = list;
|
||||
paths = map compressFirmware list;
|
||||
pathsToLink = [ "/lib/firmware" ];
|
||||
ignoreCollisions = true;
|
||||
};
|
||||
|
@ -273,9 +273,6 @@ in
|
||||
|
||||
boot.kernelModules = [ "loop" "atkbd" ];
|
||||
|
||||
# The Linux kernel >= 2.6.27 provides firmware.
|
||||
hardware.firmware = [ kernel ];
|
||||
|
||||
# Create /etc/modules-load.d/nixos.conf, which is read by
|
||||
# systemd-modules-load.service to load required kernel modules.
|
||||
environment.etc =
|
||||
|
16
pkgs/build-support/kernel/compress-firmware-xz.nix
Normal file
16
pkgs/build-support/kernel/compress-firmware-xz.nix
Normal file
@ -0,0 +1,16 @@
|
||||
{ runCommand }:
|
||||
|
||||
firmware:
|
||||
|
||||
runCommand "${firmware.name}-xz" {} ''
|
||||
mkdir -p $out/lib
|
||||
(cd ${firmware} && find lib/firmware -type d -print0) |
|
||||
(cd $out && xargs -0 mkdir -v --)
|
||||
(cd ${firmware} && find lib/firmware -type f -print0) |
|
||||
(cd $out && xargs -0tP "$NIX_BUILD_CORES" -n1 \
|
||||
sh -c 'xz -9c -T1 -C crc32 --lzma2=dict=2MiB "${firmware}/$1" > "$1.xz"' --)
|
||||
(cd ${firmware} && find lib/firmware -type l) | while read link; do
|
||||
target="$(readlink "${firmware}/$link")"
|
||||
ln -vs -- "''${target/^${firmware}/$out}.xz" "$out/$link.xz"
|
||||
done
|
||||
''
|
@ -81,8 +81,12 @@ for module in $(cat closure); do
|
||||
for i in $(modinfo -b $kernel --set-version "$version" -F firmware $module | grep -v '^name:'); do
|
||||
mkdir -p "$out/lib/firmware/$(dirname "$i")"
|
||||
echo "firmware for $module: $i"
|
||||
cp "$firmware/lib/firmware/$i" "$out/lib/firmware/$i" 2>/dev/null \
|
||||
|| echo "WARNING: missing firmware $i for module $module"
|
||||
for name in "$i" "$i.xz" ""; do
|
||||
[ -z "$name" ] && echo "WARNING: missing firmware $i for module $module"
|
||||
if cp "$firmware/lib/firmware/$name" "$out/lib/firmware/$name" 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
|
@ -14,8 +14,8 @@ stdenv.mkDerivation rec {
|
||||
sourceRoot = ".";
|
||||
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
b43-fwcutter -w $out *.wl_apsta.o
|
||||
mkdir -p $out/lib/firmware
|
||||
b43-fwcutter -w $out/lib/firmware *.wl_apsta.o
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
|
@ -883,6 +883,8 @@ let
|
||||
# Disable the firmware helper fallback, udev doesn't implement it any more
|
||||
FW_LOADER_USER_HELPER_FALLBACK = option no;
|
||||
|
||||
FW_LOADER_COMPRESS = option yes;
|
||||
|
||||
HOTPLUG_PCI_ACPI = yes; # PCI hotplug using ACPI
|
||||
HOTPLUG_PCI_PCIE = yes; # PCI-Expresscard hotplug support
|
||||
|
||||
|
@ -808,6 +808,8 @@ with pkgs;
|
||||
sanitizers = [ ];
|
||||
};
|
||||
|
||||
compressFirmwareXz = callPackage ../build-support/kernel/compress-firmware-xz.nix { };
|
||||
|
||||
makeModulesClosure = { kernel, firmware, rootModules, allowMissing ? false }:
|
||||
callPackage ../build-support/kernel/modules-closure.nix {
|
||||
inherit kernel firmware rootModules allowMissing;
|
||||
|
Loading…
Reference in New Issue
Block a user