Author: eelco
Date: Thu Sep 16 15:23:12 2010
New Revision: 23822
URL: https://svn.nixos.org/websvn/nix/?rev=23822&sc=1

Log:
* Allow modules to add packages to the $PATH seen by programs called
  from udev rules.  This is slightly tricky because udev has a
  512-character limit on environment variables, so we create a symlink
  tree to work around this.

Modified:
   nixos/trunk/modules/services/hardware/udev.nix

Modified: nixos/trunk/modules/services/hardware/udev.nix
==============================================================================
--- nixos/trunk/modules/services/hardware/udev.nix      Thu Sep 16 15:21:28 
2010        (r23821)
+++ nixos/trunk/modules/services/hardware/udev.nix      Thu Sep 16 15:23:12 
2010        (r23822)
@@ -38,7 +38,7 @@
       cp -v ${udev}/libexec/rules.d/*.rules $out/
 
       # Set a reasonable $PATH for programs called by udev rules.
-      echo 
'ENV{PATH}="${pkgs.coreutils}/bin:${pkgs.gnused}/bin:${pkgs.utillinux}/bin"' > 
$out/00-path.rules
+      echo 'ENV{PATH}="${udevPath}/bin:${udevPath}/sbin"' > $out/00-path.rules
 
       # Set the firmware search path so that the firmware.sh helper
       # called by 50-firmware.rules works properly.
@@ -84,6 +84,15 @@
     #udev_log="debug"
   '';
 
+  # Udev has a 512-character limit for ENV{PATH}, so create a symlink
+  # tree to work around this.
+  udevPath = pkgs.buildEnv {
+    name = "udev-path";
+    paths = cfg.path;
+    pathsToLink = [ "/bin" "/sbin" ];
+    ignoreCollisions = true;
+  };
+
 in
 
 {
@@ -118,6 +127,15 @@
         '';
       };
 
+      path = mkOption {
+        default = [];
+        merge = mergeListOption;
+        description = ''
+          Packages added to the <envar>PATH</envar> environment variable when
+          executing programs from Udev rules.
+        '';
+      };
+
       extraRules = mkOption {
         default = "";
         example = ''
@@ -159,7 +177,9 @@
 
     services.udev.extraRules = nixosRules;
     
-    services.udev.packages = [extraUdevRules];
+    services.udev.packages = [ extraUdevRules ];
+
+    services.udev.path = [ pkgs.coreutils pkgs.gnused pkgs.gnugrep 
pkgs.utillinux ];
 
     jobs.udev =
       { startOn = "startup";
@@ -207,7 +227,7 @@
             initctl emit -n new-devices
           '';
       };
-      
+
   };
 
 }
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to