diff --git a/modules/hardware/pcmcia.nix b/modules/hardware/pcmcia.nix index 62225a0df7a4..0ab5e35ea800 100644 --- a/modules/hardware/pcmcia.nix +++ b/modules/hardware/pcmcia.nix @@ -53,17 +53,9 @@ mkIf config.hardware.pcmcia.enable { options ]; - boot = { - kernelModules = [ "pcmcia" ]; - }; + boot.kernelModules = [ "pcmcia" ]; - services = { - udev = { - addUdevPkgs = [ pcmciaUtils ]; - }; - }; + services.udev.packages = [ pcmciaUtils ]; - environment = { - extraPackages = [ pcmciaUtils ]; - }; + environment.systemPackages = [ pcmciaUtils ]; } diff --git a/modules/hardware/video/encoder/wis-go7007.nix b/modules/hardware/video/encoder/wis-go7007.nix index 24ee27cf61d9..f242651d6330 100644 --- a/modules/hardware/video/encoder/wis-go7007.nix +++ b/modules/hardware/video/encoder/wis-go7007.nix @@ -8,18 +8,10 @@ let in { - boot = { - extraModulePackages = wisGo7007Pkg; - }; + boot.extraModulePackages = [wisGo7007Pkg]; - environment = { - extraPackages = wisGo7007Pkg; - }; + environment.extraPackages = [wisGo7007Pkg]; - services = { - udev = { - addFirmware = wisGo7007Firmware; - addUdevPkgs = wisGo7007Pkg; - }; - }; + services.udev.addFirmware = [wisGo7007Firmware]; + services.udev.packages = [wisGo7007Pkg]; } diff --git a/modules/services/hardware/hal.nix b/modules/services/hardware/hal.nix index 972e8b5e3c98..c1390dd6eee2 100644 --- a/modules/services/hardware/hal.nix +++ b/modules/services/hardware/hal.nix @@ -94,7 +94,7 @@ in exec = "${hal}/sbin/hald --daemon=no"; }; - services.udev.addUdevPkgs = [hal]; + services.udev.packages = [hal]; services.dbus.enable = true; services.dbus.packages = [hal]; diff --git a/modules/services/hardware/udev.nix b/modules/services/hardware/udev.nix index 9b69b81b7515..6c6b82d9c805 100644 --- a/modules/services/hardware/udev.nix +++ b/modules/services/hardware/udev.nix @@ -12,22 +12,18 @@ let src = ./udev-firmware-loader.sh; path = "${stdenv.coreutils}/bin"; isExecutable = true; - inherit firmwareDirs; + firmwareDirs = cfg.addFirmware; }; - firmwareDirs = config.services.udev.addFirmware; - - extraUdevPkgs = config.services.udev.addUdevPkgs - ++ pkgs.lib.optional (cfg.extraRules != "") - (pkgs.writeTextFile { - name = "extra-udev-rules"; - text = cfg.extraRules; - destination = "/custom/udev/rules.d/10-local.rules"; - }); + extraUdevRules = pkgs.writeTextFile { + name = "extra-udev-rules"; + text = cfg.extraRules; + destination = "/etc/udev/rules.d/10-local.rules"; + }; modprobe = config.system.sbin.modprobe; - nixRules = writeText "90-nix.rules" '' + nixosRules = '' # Miscellaneous devices. KERNEL=="sonypi", MODE="0666" @@ -60,10 +56,14 @@ let #src = cleanSource ./udev-rules; buildCommand = '' ensureDir $out - ln -s ${nixRules} $out/${nixRules.name} shopt -s nullglob + + # Use all the default udev rules. cp ${udev}/*/udev/rules.d/*.rules $out/ - + + # If auto-configuration is disabled, then remove + # udev's 80-drivers.rules file, which contains rules for + # automatically calling modprobe. ${if config.boot.hardwareScan then '' substituteInPlace $out/80-drivers.rules \ @@ -74,7 +74,9 @@ let rm $out/80-drivers.rules '' } - for i in ${toString extraUdevPkgs}; do + + # Add the udev rules from other packages. + for i in ${toString cfg.packages}; do for j in $i/*/udev/rules.d/*; do ln -s $j $out/$(basename $j) done @@ -122,23 +124,24 @@ in 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. ''; - merge = pkgs.lib.mergeListOption; }; - addUdevPkgs = mkOption { + packages = mkOption { default = []; + merge = mergeListOption; description = '' List of packages containing udev rules. All files found in - pkg/udev/rules.d + pkg/etc/udev/rules.d and + pkg/lib/udev/rules.d will be included. ''; - merge = pkgs.lib.mergeListOption; }; extraRules = mkOption { @@ -146,6 +149,7 @@ in example = '' KERNEL=="eth*", ATTR{address}=="00:1D:60:B9:6D:4F", NAME="my_fast_network_card" ''; + merge = mergeStringOption; description = '' Additional udev rules. They'll be written into file 10-local.rules. Thus they are @@ -172,6 +176,10 @@ in config = { + services.udev.extraRules = nixosRules; + + services.udev.packages = [extraUdevRules]; + jobs = singleton { name = "udev";