summary refs log tree commit diff
path: root/modules/services/hardware/udev.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2009-08-10 18:41:57 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2009-08-10 18:41:57 +0000
commitb4f8f919ab02af695b9ce84ad6c4c95b1c8e4afb (patch)
tree3316e6b023a7d61973efc56b3a2de0593ff70b2f /modules/services/hardware/udev.nix
parent2331a5140d0cd4be4037b394452f3f3368b734d5 (diff)
downloadnixpkgs-b4f8f919ab02af695b9ce84ad6c4c95b1c8e4afb.tar
nixpkgs-b4f8f919ab02af695b9ce84ad6c4c95b1c8e4afb.tar.gz
nixpkgs-b4f8f919ab02af695b9ce84ad6c4c95b1c8e4afb.tar.bz2
nixpkgs-b4f8f919ab02af695b9ce84ad6c4c95b1c8e4afb.tar.lz
nixpkgs-b4f8f919ab02af695b9ce84ad6c4c95b1c8e4afb.tar.xz
nixpkgs-b4f8f919ab02af695b9ce84ad6c4c95b1c8e4afb.tar.zst
nixpkgs-b4f8f919ab02af695b9ce84ad6c4c95b1c8e4afb.zip
* Clean up the udev module.
svn path=/nixos/trunk/; revision=16653
Diffstat (limited to 'modules/services/hardware/udev.nix')
-rw-r--r--modules/services/hardware/udev.nix169
1 files changed, 85 insertions, 84 deletions
diff --git a/modules/services/hardware/udev.nix b/modules/services/hardware/udev.nix
index 63c4c77e1b3..9b69b81b751 100644
--- a/modules/services/hardware/udev.nix
+++ b/modules/services/hardware/udev.nix
@@ -1,71 +1,6 @@
 {pkgs, config, ...}:
 
-###### interface
-let
-  inherit (pkgs.lib) mkOption mkIf;
-
-  options = {
-
-    boot.hardwareScan = mkOption {
-      default = true;
-      description = "
-        Whether to try to load kernel modules for all detected hardware.
-        Usually this does a good job of providing you with the modules
-        you need, but sometimes it can crash the system or cause other
-        nasty effects.  If the hardware scan is turned on, it can be
-        disabled at boot time by adding the <literal>safemode</literal>
-        parameter to the kernel command line.
-      ";
-    };
-  
-    services = {
-      udev = {
-
-        addFirmware = mkOption {
-          default = [];
-          example = ["/mnt/big-storage/firmware/"];
-          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 {
-          default = [];
-          description = "
-            List of packages containing udev rules. All files found in $out/*/udev/rules.d/*.rules will be recognized
-          ";
-          merge = pkgs.lib.mergeListOption;
-        };
-
-        extraRules = mkOption {
-          default = "";
-          example = ''
-            KERNEL=="eth*", ATTR{address}=="00:1D:60:B9:6D:4F", NAME="my_fast_network_card"
-          '';
-          description = "
-            Add custom rules. They'll be written into file 10-local.rules.
-            Thus they are read before all other rules.
-          ";
-        };
-        
-        sndMode = mkOption {
-          default = "0600";
-          example = "0666";
-          description = "
-            Permissions for /dev/snd/*, in case you have multiple 
-            logged in users or if the devices belong to root for 
-            some reason.
-          ";
-        };
-      };
-    };
-  };
-in
-
-###### implementation
+with pkgs.lib;
 
 let
 
@@ -73,7 +8,6 @@ let
 
   cfg = config.services.udev;
 
-
   firmwareLoader = substituteAll {
     src = ./udev-firmware-loader.sh;
     path = "${stdenv.coreutils}/bin";
@@ -82,6 +16,7 @@ let
   };
 
   firmwareDirs = config.services.udev.addFirmware;
+  
   extraUdevPkgs = config.services.udev.addUdevPkgs
     ++ pkgs.lib.optional (cfg.extraRules != "")
       (pkgs.writeTextFile {
@@ -166,21 +101,87 @@ in
 
 {
 
-  require = [
-    options
-  ];
+  ###### interface
+  
+  options = {
 
-  services = {
-    extraJobs = [{
-      name = "udev";
-      
-      job = ''
-        start on startup
-        stop on shutdown
+    boot.hardwareScan = mkOption {
+      default = true;
+      description = ''
+        Whether to try to load kernel modules for all detected hardware.
+        Usually this does a good job of providing you with the modules
+        you need, but sometimes it can crash the system or cause other
+        nasty effects.  If the hardware scan is turned on, it can be
+        disabled at boot time by adding the <literal>safemode</literal>
+        parameter to the kernel command line.
+      '';
+    };
+  
+    services.udev = {
+
+      addFirmware = mkOption {
+        default = [];
+        example = ["/mnt/big-storage/firmware/"];
+        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 {
+        default = [];
+        description = ''
+          List of packages containing <command>udev</command> rules.
+          All files found in
+          <filename><replaceable>pkg</replaceable>/udev/rules.d</filename>
+          will be included.
+        '';
+        merge = pkgs.lib.mergeListOption;
+      };
 
-        env UDEV_CONFIG_FILE=${conf}
+      extraRules = mkOption {
+        default = "";
+        example = ''
+          KERNEL=="eth*", ATTR{address}=="00:1D:60:B9:6D:4F", NAME="my_fast_network_card"
+        '';
+        description = ''
+          Additional <command>udev</command> rules. They'll be written
+          into file <filename>10-local.rules</filename>. Thus they are
+          read before all other rules.
+        '';
+      };
 
-        start script
+      sndMode = mkOption {
+        default = "0600";
+        example = "0666";
+        description = ''
+          Permissions for sound devices, in case you have multiple
+          logged in users or if the devices belong to root for some
+          reason.
+        '';
+      };
+        
+    };
+    
+  };
+  
+
+  ###### implementation
+
+  config = {
+
+    jobs = singleton
+      { name = "udev";
+
+        startOn = "startup";
+        stopOn = "shutdown";
+
+        environment = { UDEV_CONFIG_FILE = conf; };
+
+        preStart =
+          ''
             echo "" > /proc/sys/kernel/hotplug
 
             # Get rid of possible old udev processes.
@@ -217,12 +218,12 @@ in
             done
 
             initctl emit new-devices
-        end script
+          '';
 
-        respawn ${udev}/sbin/udevd
-      '';
+        exec = "${udev}/sbin/udevd";
+
+      };
 
-      passthru = {inherit udevRules;};
-    }];
   };
+
 }