From 167ccdd537224017168619fdf8d86a5401255852 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 10 Aug 2009 19:27:15 +0000 Subject: [PATCH] * Move the firmware loader into a separate module. * services.udev.addFirmware -> hardware.firmware. svn path=/nixos/trunk/; revision=16657 --- modules/hardware/network/intel-2200bg.nix | 2 +- modules/hardware/network/intel-3945abg.nix | 2 +- modules/hardware/network/intel-4965agn.nix | 18 +------ modules/hardware/network/intel-5000.nix | 6 +-- modules/hardware/network/zydas-zd1211.nix | 6 +-- modules/hardware/video/encoder/wis-go7007.nix | 14 +++-- modules/module-list.nix | 1 + modules/services/hardware/firmware.nix | 51 +++++++++++++++++++ modules/services/hardware/udev.nix | 23 +-------- modules/system/boot/kernel.nix | 19 ++----- 10 files changed, 68 insertions(+), 74 deletions(-) create mode 100644 modules/services/hardware/firmware.nix diff --git a/modules/hardware/network/intel-2200bg.nix b/modules/hardware/network/intel-2200bg.nix index 382f7b78bd93..dc67e1335fe8 100644 --- a/modules/hardware/network/intel-2200bg.nix +++ b/modules/hardware/network/intel-2200bg.nix @@ -27,7 +27,7 @@ # Warning: setting this option requires acceptance of the firmware # license, see http://ipw2200.sourceforge.net/firmware.php?fid=7. - services.udev.addFirmware = [ pkgs.ipw2200fw ]; + hardware.firmware = [ pkgs.ipw2200fw ]; }; diff --git a/modules/hardware/network/intel-3945abg.nix b/modules/hardware/network/intel-3945abg.nix index 5468f7bc18df..9fe4be500f1e 100644 --- a/modules/hardware/network/intel-3945abg.nix +++ b/modules/hardware/network/intel-3945abg.nix @@ -22,7 +22,7 @@ config = pkgs.lib.mkIf config.networking.enableIntel3945ABGFirmware { - services.udev.addFirmware = [ pkgs.iwlwifi3945ucode ]; + hardware.firmware = [ pkgs.iwlwifi3945ucode ]; }; diff --git a/modules/hardware/network/intel-4965agn.nix b/modules/hardware/network/intel-4965agn.nix index c0eb413e2d2c..d22eea296971 100644 --- a/modules/hardware/network/intel-4965agn.nix +++ b/modules/hardware/network/intel-4965agn.nix @@ -1,21 +1,5 @@ {pkgs, config, ...}: -let - inherit (config.boot) kernelPackages; - inherit (kernelPackages) kernel; -in - { - boot = { - extraModulePackages = - pkgs.lib.optional - (!kernel.features ? iwlwifi) - kernelPackages.iwlwifi; - }; - - services = { - udev = { - addFirmware = [ kernelPackages.iwlwifi4965ucode ]; - }; - }; + hardware.firmware = [ config.boot.kernelPackages.iwlwifi4965ucode ]; } diff --git a/modules/hardware/network/intel-5000.nix b/modules/hardware/network/intel-5000.nix index 0b0d29fe6df3..19e6499fa992 100644 --- a/modules/hardware/network/intel-5000.nix +++ b/modules/hardware/network/intel-5000.nix @@ -1,9 +1,5 @@ {pkgs, config, ...}: { - services = { - udev = { - addFirmware = [ pkgs.iwlwifi5000ucode ]; - }; - }; + hardware.firmware = [ pkgs.iwlwifi5000ucode ]; } diff --git a/modules/hardware/network/zydas-zd1211.nix b/modules/hardware/network/zydas-zd1211.nix index a57e8a6cf95d..c8428a7241b1 100644 --- a/modules/hardware/network/zydas-zd1211.nix +++ b/modules/hardware/network/zydas-zd1211.nix @@ -1,9 +1,5 @@ {pkgs, config, ...}: { - services = { - udev = { - addFirmware = [ pkgs.zd1211fw ]; - }; - }; + hardware.firmware = [ pkgs.zd1211fw ]; } diff --git a/modules/hardware/video/encoder/wis-go7007.nix b/modules/hardware/video/encoder/wis-go7007.nix index f242651d6330..3936b333af4c 100644 --- a/modules/hardware/video/encoder/wis-go7007.nix +++ b/modules/hardware/video/encoder/wis-go7007.nix @@ -1,17 +1,15 @@ {pkgs, config, ...}: let - wisGo7007 = config.boot.kernelPackages.wis_go7007; - - wisGo7007Pkg = [ wis_go7007 ]; - wisGo7007Firmware = [ "${wis_go7007}/firmware" ]; + wis_go7007 = config.boot.kernelPackages.wis_go7007; in { - boot.extraModulePackages = [wisGo7007Pkg]; + boot.extraModulePackages = [wis_go7007]; - environment.extraPackages = [wisGo7007Pkg]; + environment.systemPackages = [wis_go7007]; - services.udev.addFirmware = [wisGo7007Firmware]; - services.udev.packages = [wisGo7007Pkg]; + hardware.firmware = ["${wis_go7007}/firmware"]; + + services.udev.packages = [wis_go7007]; } diff --git a/modules/module-list.nix b/modules/module-list.nix index 9938cc6e1b59..d3290226b9a8 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -31,6 +31,7 @@ ./services/databases/mysql.nix ./services/databases/postgresql.nix ./services/hardware/acpid.nix + ./services/hardware/firmware.nix ./services/hardware/hal.nix ./services/hardware/udev.nix ./services/logging/klogd.nix diff --git a/modules/services/hardware/firmware.nix b/modules/services/hardware/firmware.nix new file mode 100644 index 000000000000..0ed5fb31f98c --- /dev/null +++ b/modules/services/hardware/firmware.nix @@ -0,0 +1,51 @@ +# This module provides support for automatic loading of firmware from +# kernel modules. +{pkgs, config, ...}: + +with pkgs.lib; + +let + + firmwareLoader = pkgs.substituteAll { + src = ./udev-firmware-loader.sh; + path = "${pkgs.coreutils}/bin"; + isExecutable = true; + firmwareDirs = config.hardware.firmware; + }; + +in + +{ + + ###### interface + + options = { + + hardware.firmware = mkOption { + default = []; + example = ["/root/my-firmware"]; + merge = mergeListOption; + description = '' + List of directories 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). + ''; + }; + + }; + + + ###### implementation + + config = { + + services.udev.extraRules = + '' + # Firmware loading. + SUBSYSTEM=="firmware", ACTION=="add", RUN+="${firmwareLoader}" + ''; + + }; + +} diff --git a/modules/services/hardware/udev.nix b/modules/services/hardware/udev.nix index 6c6b82d9c805..d1e22efc58aa 100644 --- a/modules/services/hardware/udev.nix +++ b/modules/services/hardware/udev.nix @@ -4,17 +4,10 @@ with pkgs.lib; let - inherit (pkgs) substituteAll stdenv writeText udev procps; + inherit (pkgs) stdenv writeText udev procps; cfg = config.services.udev; - firmwareLoader = substituteAll { - src = ./udev-firmware-loader.sh; - path = "${stdenv.coreutils}/bin"; - isExecutable = true; - firmwareDirs = cfg.addFirmware; - }; - extraUdevRules = pkgs.writeTextFile { name = "extra-udev-rules"; text = cfg.extraRules; @@ -45,9 +38,6 @@ let KERNEL=="timer", NAME="snd/%k", MODE="${cfg.sndMode}" KERNEL=="seq", NAME="snd/%k", MODE="${cfg.sndMode}" - # Firmware loading. - SUBSYSTEM=="firmware", ACTION=="add", RUN+="${firmwareLoader}" - ''; # Perform substitutions in all udev rules files. @@ -121,17 +111,6 @@ in services.udev = { - addFirmware = mkOption { - default = []; - example = ["/mnt/big-storage/firmware/"]; - merge = mergeListOption; - description = '' - To specify firmware that is not too spread to ensure - a package, or have an interactive process of extraction - and cannot be redistributed. - ''; - }; - packages = mkOption { default = []; merge = mergeListOption; diff --git a/modules/system/boot/kernel.nix b/modules/system/boot/kernel.nix index 6320526a31cc..2d5050f76b88 100644 --- a/modules/system/boot/kernel.nix +++ b/modules/system/boot/kernel.nix @@ -179,21 +179,10 @@ let in { - require = [ - options + require = [options]; - # udev - ]; + system.modulesTree = [ kernel ] ++ config.boot.extraModulePackages; - system = { - # include kernel modules. - modulesTree = [ kernel ] ++ config.boot.extraModulePackages; - }; - - services = { - udev = { - # The Linux kernel >= 2.6.27 provides firmware - addFirmware = [ "${kernel}/lib/firmware" ]; - }; - }; + # The Linux kernel >= 2.6.27 provides firmware. + hardware.firmware = [ "${kernel}/lib/firmware" ]; }