Put all firmware in $out/lib/firmware

This way, hardware.firmware can be a list of packages.
This commit is contained in:
Eelco Dolstra 2015-08-25 00:27:06 +02:00
parent ce6daa507a
commit 9c61317002
8 changed files with 24 additions and 28 deletions

View File

@ -22,9 +22,7 @@ with lib;
###### implementation ###### implementation
config = mkIf config.hardware.enableAllFirmware { config = mkIf config.hardware.enableAllFirmware {
hardware.firmware = [ hardware.firmware = [ pkgs.firmwareLinuxNonfree ];
"${pkgs.firmwareLinuxNonfree}/lib/firmware"
];
}; };
} }

View File

@ -9,7 +9,7 @@ in
environment.systemPackages = [ wis_go7007 ]; environment.systemPackages = [ wis_go7007 ];
hardware.firmware = ["${wis_go7007}/firmware"]; hardware.firmware = [ wis_go7007 ];
services.udev.packages = [ wis_go7007 ]; services.udev.packages = [ wis_go7007 ];
} }

View File

@ -171,25 +171,23 @@ in
}; };
hardware.firmware = mkOption { hardware.firmware = mkOption {
type = types.listOf types.path; type = types.listOf types.package;
default = []; default = [];
description = '' description = ''
List of directories containing firmware files. Such files List of packages containing firmware files. Such files
will be loaded automatically if the kernel asks for them will be loaded automatically if the kernel asks for them
(i.e., when it has detected specific hardware that requires (i.e., when it has detected specific hardware that requires
firmware to function). If more than one path contains a firmware to function). If multiple packages contain firmware
firmware file with the same name, the first path in the list files with the same name, the first package in the list takes
takes precedence. Note that you must rebuild your system if precedence. Note that you must rebuild your system if you add
you add files to any of these directories. For quick testing, files to any of these directories. For quick testing,
put firmware files in <filename>/root/test-firmware</filename> put firmware files in <filename>/root/test-firmware</filename>
and add that directory to the list. Note that you can also and add that directory to the list.
add firmware packages to this list as these are directories in
the nix store.
''; '';
apply = list: pkgs.buildEnv { apply = list: pkgs.buildEnv {
name = "firmware"; name = "firmware";
paths = list; paths = list;
pathsToLink = [ "/" ]; pathsToLink = [ "/lib/firmware" ];
ignoreCollisions = true; ignoreCollisions = true;
}; };
}; };
@ -236,7 +234,7 @@ in
(isYes "NET") (isYes "NET")
]; ];
boot.extraModprobeConfig = "options firmware_class path=${config.hardware.firmware}"; boot.extraModprobeConfig = "options firmware_class path=${config.hardware.firmware}/lib/firmware";
system.activationScripts.udevd = system.activationScripts.udevd =
'' ''
@ -254,7 +252,7 @@ in
# Allow the kernel to find our firmware. # Allow the kernel to find our firmware.
if [ -e /sys/module/firmware_class/parameters/path ]; then if [ -e /sys/module/firmware_class/parameters/path ]; then
echo -n "${config.hardware.firmware}" > /sys/module/firmware_class/parameters/path echo -n "${config.hardware.firmware}/lib/firmware" > /sys/module/firmware_class/parameters/path
fi fi
''; '';

View File

@ -50,7 +50,7 @@ let
ln -s ${config.system.build.initialRamdisk}/initrd $out/initrd ln -s ${config.system.build.initialRamdisk}/initrd $out/initrd
ln -s ${config.hardware.firmware} $out/firmware ln -s ${config.hardware.firmware}/lib/firmware $out/firmware
''} ''}
echo "$activationScript" > $out/activate echo "$activationScript" > $out/activate

View File

@ -216,7 +216,7 @@ in
]; ];
# The Linux kernel >= 2.6.27 provides firmware. # The Linux kernel >= 2.6.27 provides firmware.
hardware.firmware = [ "${kernel}/lib/firmware" ]; hardware.firmware = [ kernel ];
# Create /etc/modules-load.d/nixos.conf, which is read by # Create /etc/modules-load.d/nixos.conf, which is read by
# systemd-modules-load.service to load required kernel modules. # systemd-modules-load.service to load required kernel modules.

View File

@ -15,8 +15,8 @@ stdenv.mkDerivation {
phases = [ "unpackPhase" "installPhase" ]; phases = [ "unpackPhase" "installPhase" ];
installPhase = '' installPhase = ''
mkdir $out mkdir -p $out/lib/firmware
b43-fwcutter -w $out linux/wl_apsta.o b43-fwcutter -w $out/lib/firmware linux/wl_apsta.o
''; '';
meta = { meta = {

View File

@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
buildPhase = "true"; buildPhase = "true";
installPhase = "mkdir -p $out/zd1211; cp * $out/zd1211"; installPhase = "mkdir -p $out/lib/firmware/zd1211; cp * $out/lib/firmware/zd1211";
meta = { meta = {
description = "Firmware for the ZyDAS ZD1211(b) 802.11a/b/g USB WLAN chip"; description = "Firmware for the ZyDAS ZD1211(b) 802.11a/b/g USB WLAN chip";

View File

@ -56,7 +56,7 @@ stdenv.mkDerivation {
mkdir -p $out/etc/udev/rules.d mkdir -p $out/etc/udev/rules.d
makeFlagsArray=(KERNELSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source \ makeFlagsArray=(KERNELSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source \
FIRMWARE_DIR=$out/firmware FXLOAD=${fxload}/sbin/fxload \ FIRMWARE_DIR=$out/lib/firmware FXLOAD=${fxload}/sbin/fxload \
DESTDIR=$out SKIP_DEPMOD=1 \ DESTDIR=$out SKIP_DEPMOD=1 \
USE_UDEV=y) USE_UDEV=y)
''; # */ ''; # */