From 9c61317002edf32812d793aebac86a990edcd1cb Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 25 Aug 2015 00:27:06 +0200 Subject: [PATCH] Put all firmware in $out/lib/firmware This way, hardware.firmware can be a list of packages. --- nixos/modules/hardware/all-firmware.nix | 4 +--- .../hardware/video/encoder/wis-go7007.nix | 8 +++---- nixos/modules/services/hardware/udev.nix | 22 +++++++++---------- nixos/modules/system/activation/top-level.nix | 2 +- nixos/modules/system/boot/kernel.nix | 2 +- .../linux/firmware/b43-firmware/5.1.138.nix | 4 ++-- .../linux/firmware/zd1211/default.nix | 8 +++---- pkgs/os-specific/linux/wis-go7007/default.nix | 2 +- 8 files changed, 24 insertions(+), 28 deletions(-) diff --git a/nixos/modules/hardware/all-firmware.nix b/nixos/modules/hardware/all-firmware.nix index e4bdeb55cad..1a04baef193 100644 --- a/nixos/modules/hardware/all-firmware.nix +++ b/nixos/modules/hardware/all-firmware.nix @@ -22,9 +22,7 @@ with lib; ###### implementation config = mkIf config.hardware.enableAllFirmware { - hardware.firmware = [ - "${pkgs.firmwareLinuxNonfree}/lib/firmware" - ]; + hardware.firmware = [ pkgs.firmwareLinuxNonfree ]; }; } diff --git a/nixos/modules/hardware/video/encoder/wis-go7007.nix b/nixos/modules/hardware/video/encoder/wis-go7007.nix index c0eb2b814b3..e9b3cf72a8d 100644 --- a/nixos/modules/hardware/video/encoder/wis-go7007.nix +++ b/nixos/modules/hardware/video/encoder/wis-go7007.nix @@ -5,11 +5,11 @@ let in { - boot.extraModulePackages = [wis_go7007]; + boot.extraModulePackages = [ wis_go7007 ]; - 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 ]; } diff --git a/nixos/modules/services/hardware/udev.nix b/nixos/modules/services/hardware/udev.nix index fc89de777e8..513eb27b406 100644 --- a/nixos/modules/services/hardware/udev.nix +++ b/nixos/modules/services/hardware/udev.nix @@ -171,25 +171,23 @@ in }; hardware.firmware = mkOption { - type = types.listOf types.path; + type = types.listOf types.package; default = []; 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 (i.e., when it has detected specific hardware that requires - firmware to function). If more than one path contains a - firmware file with the same name, the first path in the list - takes precedence. Note that you must rebuild your system if - you add files to any of these directories. For quick testing, + firmware to function). If multiple packages contain firmware + files with the same name, the first package in the list takes + precedence. Note that you must rebuild your system if you add + files to any of these directories. For quick testing, put firmware files in /root/test-firmware - and add that directory to the list. Note that you can also - add firmware packages to this list as these are directories in - the nix store. + and add that directory to the list. ''; apply = list: pkgs.buildEnv { name = "firmware"; paths = list; - pathsToLink = [ "/" ]; + pathsToLink = [ "/lib/firmware" ]; ignoreCollisions = true; }; }; @@ -236,7 +234,7 @@ in (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 = '' @@ -254,7 +252,7 @@ in # Allow the kernel to find our firmware. 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 ''; diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index 83930079816..a977ddb7bb4 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -50,7 +50,7 @@ let 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 diff --git a/nixos/modules/system/boot/kernel.nix b/nixos/modules/system/boot/kernel.nix index ae868219aa4..ac40e8a49ac 100644 --- a/nixos/modules/system/boot/kernel.nix +++ b/nixos/modules/system/boot/kernel.nix @@ -216,7 +216,7 @@ in ]; # 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 # systemd-modules-load.service to load required kernel modules. diff --git a/pkgs/os-specific/linux/firmware/b43-firmware/5.1.138.nix b/pkgs/os-specific/linux/firmware/b43-firmware/5.1.138.nix index 436f40712fc..1cc0e7ae4ca 100644 --- a/pkgs/os-specific/linux/firmware/b43-firmware/5.1.138.nix +++ b/pkgs/os-specific/linux/firmware/b43-firmware/5.1.138.nix @@ -15,8 +15,8 @@ stdenv.mkDerivation { phases = [ "unpackPhase" "installPhase" ]; installPhase = '' - mkdir $out - b43-fwcutter -w $out linux/wl_apsta.o + mkdir -p $out/lib/firmware + b43-fwcutter -w $out/lib/firmware linux/wl_apsta.o ''; meta = { diff --git a/pkgs/os-specific/linux/firmware/zd1211/default.nix b/pkgs/os-specific/linux/firmware/zd1211/default.nix index 96e534e3b80..19cbdecca0c 100644 --- a/pkgs/os-specific/linux/firmware/zd1211/default.nix +++ b/pkgs/os-specific/linux/firmware/zd1211/default.nix @@ -5,16 +5,16 @@ stdenv.mkDerivation rec { version = "1.5"; name = "${pname}-${version}"; - + src = fetchurl { url = "mirror://sourceforge/zd1211/${name}.tar.bz2"; sha256 = "04ibs0qw8bh6h6zmm5iz6lddgknwhsjq8ib3gyck6a7psw83h7gi"; }; - + buildPhase = "true"; - installPhase = "mkdir -p $out/zd1211; cp * $out/zd1211"; - + installPhase = "mkdir -p $out/lib/firmware/zd1211; cp * $out/lib/firmware/zd1211"; + meta = { description = "Firmware for the ZyDAS ZD1211(b) 802.11a/b/g USB WLAN chip"; homepage = http://sourceforge.net/projects/zd1211/; diff --git a/pkgs/os-specific/linux/wis-go7007/default.nix b/pkgs/os-specific/linux/wis-go7007/default.nix index 53868672025..4dae68d4871 100644 --- a/pkgs/os-specific/linux/wis-go7007/default.nix +++ b/pkgs/os-specific/linux/wis-go7007/default.nix @@ -56,7 +56,7 @@ stdenv.mkDerivation { mkdir -p $out/etc/udev/rules.d 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 \ USE_UDEV=y) ''; # */