From 82f97b5fb2cb05693d549eedb0d10c143f8cf0fb Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 16 Sep 2010 15:23:12 +0000 Subject: [PATCH] * 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. svn path=/nixos/trunk/; revision=23822 --- modules/services/hardware/udev.nix | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/modules/services/hardware/udev.nix b/modules/services/hardware/udev.nix index c3661e0c0b55..e84150d24927 100644 --- a/modules/services/hardware/udev.nix +++ b/modules/services/hardware/udev.nix @@ -38,7 +38,7 @@ let 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 @@ let #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 @@ in ''; }; + path = mkOption { + default = []; + merge = mergeListOption; + description = '' + Packages added to the PATH environment variable when + executing programs from Udev rules. + ''; + }; + extraRules = mkOption { default = ""; example = '' @@ -159,7 +177,9 @@ in 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 @@ in initctl emit -n new-devices ''; }; - + }; }