summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authorYury G. Kudryashov <urkud.urkud@gmail.com>2011-08-24 21:24:39 +0000
committerYury G. Kudryashov <urkud.urkud@gmail.com>2011-08-24 21:24:39 +0000
commite5917ea6fc26ecf52b5db6ccf2bb8bfc8c507854 (patch)
tree1c1875f5d22e19cc7c5100bbd940b78e355ab618 /modules
parent1aa1c86afc5ac6e11162fb55f0113b7c58936c8a (diff)
downloadnixlib-e5917ea6fc26ecf52b5db6ccf2bb8bfc8c507854.tar
nixlib-e5917ea6fc26ecf52b5db6ccf2bb8bfc8c507854.tar.gz
nixlib-e5917ea6fc26ecf52b5db6ccf2bb8bfc8c507854.tar.bz2
nixlib-e5917ea6fc26ecf52b5db6ccf2bb8bfc8c507854.tar.lz
nixlib-e5917ea6fc26ecf52b5db6ccf2bb8bfc8c507854.tar.xz
nixlib-e5917ea6fc26ecf52b5db6ccf2bb8bfc8c507854.tar.zst
nixlib-e5917ea6fc26ecf52b5db6ccf2bb8bfc8c507854.zip
Merge with udev-173
The only conflict was the addition of two different options at the same place.

svn path=/nixos/trunk/; revision=28801
Diffstat (limited to 'modules')
-rw-r--r--modules/services/hardware/udev.nix52
-rw-r--r--modules/services/hardware/udisks.nix1
-rw-r--r--modules/services/hardware/upower.nix2
-rw-r--r--modules/services/system/dbus.nix2
-rw-r--r--modules/system/boot/stage-1.nix37
5 files changed, 63 insertions, 31 deletions
diff --git a/modules/services/hardware/udev.nix b/modules/services/hardware/udev.nix
index 7b4f86b93cbf..73ec53e04e75 100644
--- a/modules/services/hardware/udev.nix
+++ b/modules/services/hardware/udev.nix
@@ -34,9 +34,6 @@ let
       ensureDir $out
       shopt -s nullglob
 
-      # Use all the default udev rules.
-      cp -v ${udev}/libexec/rules.d/*.rules $out/
-
       # Set a reasonable $PATH for programs called by udev rules.
       echo 'ENV{PATH}="${udevPath}/bin:${udevPath}/sbin"' > $out/00-path.rules
 
@@ -48,19 +45,19 @@ let
       for i in ${toString cfg.packages}; do
         echo "Adding rules for package $i"
         for j in $i/*/udev/rules.d/*; do
-          ln -sv $j $out/$(basename $j)
+          echo "Copying $j to $out/$(basename $j)"
+          echo "# Copied from $j" > $out/$(basename $j)
+          cat $j >> $out/$(basename $j)
         done
       done
 
       # Fix some paths in the standard udev rules.  Hacky.
       for i in $out/*.rules; do
         substituteInPlace $i \
-          --replace /sbin/modprobe ${modprobe}/sbin/modprobe \
-          --replace /sbin/blkid ${pkgs.utillinux}/sbin/blkid \
-          --replace /sbin/mdadm ${pkgs.mdadm}/sbin/mdadm \
-          --replace '$env{DM_SBIN_PATH}/blkid' ${pkgs.utillinux}/sbin/blkid \
-          --replace 'ENV{DM_SBIN_PATH}="/sbin"' 'ENV{DM_SBIN_PATH}="${pkgs.lvm2}/sbin"' \
-          --replace /bin/mount ${pkgs.utillinux}/bin/mount
+          --replace \"/sbin/modprobe \"${modprobe}/sbin/modprobe \
+          --replace \"/sbin/mdadm \"${pkgs.mdadm}/sbin/mdadm \
+          --replace \"/sbin/blkid \"${pkgs.utillinux}/sbin/blkid \
+          --replace \"/bin/mount \"${pkgs.utillinux}/bin/mount
       done
 
       # If auto-configuration is disabled, then remove
@@ -68,6 +65,39 @@ let
       # automatically calling modprobe.
       ${if !config.boot.hardwareScan then "rm $out/80-drivers.rules" else ""}
 
+      echo -n "Checking that all programs called by relative paths in udev rules exist in ${udev}/lib/udev ... "
+      import_progs=$(grep 'IMPORT{program}="[^/$]' $out/* |
+        sed -e 's/.*IMPORT{program}="\([^ "]*\)[ "].*/\1/' | uniq)
+      run_progs=$(grep 'RUN+="[^/$]' $out/* |
+        sed -e 's/.*RUN+="\([^ "]*\)[ "].*/\1/' | uniq)
+      for i in $import_progs $run_progs; do
+        if [[ ! -x ${pkgs.udev}/lib/udev/$i ]]; then
+          echo "FAIL"
+          echo "$i is called in udev rules but not installed by udev"
+          exit 1
+        fi
+      done
+      echo "OK"
+
+      echo -n "Checking that all programs call by absolute paths in udev rules exist ... "
+      import_progs=$(grep 'IMPORT{program}="/' $out/* |
+        sed -e 's/.*IMPORT{program}="\([^ "]*\)[ "].*/\1/' | uniq)
+      run_progs=$(grep 'RUN+="/' $out/* |
+        sed -e 's/.*RUN+="\([^ "]*\)[ "].*/\1/' | uniq)
+      for i in $import_progs $run_progs; do
+        if [[ ! -x $i ]]; then
+          echo "FAIL"
+          echo "$i is called in udev rules but not installed by udev"
+          exit 1
+        fi
+      done
+      echo "OK"
+
+      echo "Consider fixing the following udev rules:"
+      for i in ${toString cfg.packages}; do
+        grep -l '\(RUN+\|IMPORT{program}\)="\(/usr\)\?/s\?bin' $i/*/udev/rules.d/* || true
+      done
+
       # Use the persistent device rules (naming for CD/DVD and
       # network devices) stored in 
       # /var/lib/udev/rules.d/70-persistent-{cd,net}.rules.  These are
@@ -178,7 +208,7 @@ in
 
     services.udev.extraRules = nixosRules;
     
-    services.udev.packages = [ extraUdevRules ];
+    services.udev.packages = [ pkgs.udev extraUdevRules ];
 
     services.udev.path = [ pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.utillinux pkgs.udev ];
 
diff --git a/modules/services/hardware/udisks.nix b/modules/services/hardware/udisks.nix
index 8d526e22bad1..21749da424ee 100644
--- a/modules/services/hardware/udisks.nix
+++ b/modules/services/hardware/udisks.nix
@@ -38,6 +38,7 @@ with pkgs.lib;
         mkdir -m 0755 -p /var/lib/udisks
       '';
 
+    services.udev.packages = [ pkgs.udisks ];
   };
 
 }
diff --git a/modules/services/hardware/upower.nix b/modules/services/hardware/upower.nix
index c529e8b3cdb0..8e7cf23900ce 100644
--- a/modules/services/hardware/upower.nix
+++ b/modules/services/hardware/upower.nix
@@ -33,6 +33,8 @@ with pkgs.lib;
 
     services.dbus.packages = [ pkgs.upower ];
 
+    services.udev.packages = [ pkgs.upower ];
+
   };
 
 }
diff --git a/modules/services/system/dbus.nix b/modules/services/system/dbus.nix
index e083707751a4..e33adbe4feaf 100644
--- a/modules/services/system/dbus.nix
+++ b/modules/services/system/dbus.nix
@@ -17,7 +17,7 @@ let
     buildCommand = ''
       ensureDir $out
       
-      cp ${dbus}/etc/dbus-1/system.conf $out/system.conf
+      cp -v ${dbus}/etc/dbus-1/system.conf $out/system.conf
 
       # !!! Hm, these `sed' calls are rather error-prone...
 
diff --git a/modules/system/boot/stage-1.nix b/modules/system/boot/stage-1.nix
index e4f935d7253c..c4e934610152 100644
--- a/modules/system/boot/stage-1.nix
+++ b/modules/system/boot/stage-1.nix
@@ -15,7 +15,7 @@ let
       default = "";
       example = "0:0";
       description = "
-        Device for manual resume attempt during boot. Looks like 
+        Device for manual resume attempt during boot. Looks like
         major:minor. ls -l /dev/SWAP_PARTION shows them.
       ";
     };
@@ -74,7 +74,7 @@ let
         ";
       };
     };
-  
+
   };
 
 
@@ -107,7 +107,7 @@ let
     ''
       ensureDir $out/bin
       ensureDir $out/lib
-      
+
       # Copy what we need from Glibc.
       cp -pv ${pkgs.glibc}/lib/ld*.so.? $out/lib
       cp -pv ${pkgs.glibc}/lib/libc.so.* $out/lib
@@ -133,7 +133,7 @@ let
       cp -v ${pkgs.coreutils}/bin/sleep $out/bin
       cp -v ${pkgs.coreutils}/bin/ln $out/bin
 
-      # Copy e2fsck and friends.      
+      # Copy e2fsck and friends.
       cp -v ${pkgs.e2fsprogs}/sbin/e2fsck $out/bin
       cp -v ${pkgs.e2fsprogs}/sbin/tune2fs $out/bin
       cp -v ${pkgs.reiserfsprogs}/sbin/reiserfsck $out/bin
@@ -154,9 +154,9 @@ let
 
       # Copy udev.
       cp -v ${pkgs.udev}/sbin/udevd ${pkgs.udev}/sbin/udevadm $out/bin
-      cp -v ${pkgs.udev}/libexec/*_id $out/bin
+      cp -v ${pkgs.udev}/lib/udev/*_id $out/bin
       cp -pdv ${pkgs.udev}/lib/libudev.so.* $out/lib
-      
+
       # Copy bash.
       cp -v ${pkgs.bash}/bin/bash $out/bin
       ln -sv bash $out/bin/sh
@@ -191,7 +191,7 @@ let
       exec $out/bin/modprobe.real "\$@"
       EOF
       chmod u+x $out/bin/modprobe
-      
+
       # Make sure that the patchelf'ed binaries still work.
       echo "testing patched programs..."
       $out/bin/bash --version | grep "bash, version"
@@ -209,7 +209,7 @@ let
       $out/bin/basename --version
       $out/bin/modprobe --version
     ''; # */
-  
+
 
   # The initrd only has to mount / or any FS marked as necessary for
   # booting (such as the FS containing /nix/store, or an FS needed for
@@ -225,12 +225,12 @@ let
       ensureDir $out
 
       echo 'ENV{LD_LIBRARY_PATH}="${extraUtils}/lib"' > $out/00-env.rules
-      
-      cp ${pkgs.udev}/libexec/rules.d/60-cdrom_id.rules $out/
-      cp ${pkgs.udev}/libexec/rules.d/60-persistent-storage.rules $out/
-      cp ${pkgs.udev}/libexec/rules.d/80-drivers.rules $out/
-      cp ${pkgs.lvm2}/lib/udev/rules.d/*.rules $out/
-      cp ${pkgs.mdadm}/lib/udev/rules.d/*.rules $out/
+
+      cp -v ${pkgs.udev}/lib/udev/rules.d/60-cdrom_id.rules $out/
+      cp -v ${pkgs.udev}/lib/udev/rules.d/60-persistent-storage.rules $out/
+      cp -v ${pkgs.udev}/lib/udev/rules.d/80-drivers.rules $out/
+      cp -v ${pkgs.lvm2}/lib/udev/rules.d/*.rules $out/
+      cp -v ${pkgs.mdadm}/lib/udev/rules.d/*.rules $out/
 
       for i in $out/*.rules; do
           substituteInPlace $i \
@@ -243,10 +243,9 @@ let
             --replace /sbin/blkid ${extraUtils}/bin/blkid \
             --replace /sbin/modprobe ${extraUtils}/bin/modprobe \
             --replace '$env{DM_SBIN_PATH}/blkid' ${extraUtils}/bin/blkid \
-            --replace 'ENV{DM_SBIN_PATH}="/sbin"' 'ENV{DM_SBIN_PATH}="${extraUtils}/bin"' \
+            --replace 'ENV{DM_SBIN_PATH}="${pkgs.lvm2}/sbin"' 'ENV{DM_SBIN_PATH}="${extraUtils}/bin"' \
             --replace /sbin/mdadm ${extraUtils}/bin/mdadm
       done
-
       # !!! Remove this after merging the x-updates branch:
 
       # Work around a bug in QEMU, which doesn't implement the "READ
@@ -264,13 +263,13 @@ let
     ''; # */
   };
 
-  
+
   # The udev configuration file for in the initrd.
   udevConf = pkgs.writeText "udev-initrd.conf" ''
     udev_rules="${udevRules}"
     #udev_log="debug"
   '';
-  
+
 
   # The init script of boot stage 1 (loading kernel modules for
   # mounting the root FS).
@@ -319,7 +318,7 @@ let
           }
         ];
   };
-  
+
 in {
 
   require = [options];