summary refs log tree commit diff
path: root/pkgs/os-specific/linux/module-init-tools/aggregator.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2009-04-20 19:13:40 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2009-04-20 19:13:40 +0000
commit089eef511c7e865867d6abf7a22bc2df8cacbf99 (patch)
tree9dd57513ae950609ce6d087f0ebc454c1a606515 /pkgs/os-specific/linux/module-init-tools/aggregator.nix
parent15f1feb702f1213484e952a23981d1816e2ce98f (diff)
downloadnixpkgs-089eef511c7e865867d6abf7a22bc2df8cacbf99.tar
nixpkgs-089eef511c7e865867d6abf7a22bc2df8cacbf99.tar.gz
nixpkgs-089eef511c7e865867d6abf7a22bc2df8cacbf99.tar.bz2
nixpkgs-089eef511c7e865867d6abf7a22bc2df8cacbf99.tar.lz
nixpkgs-089eef511c7e865867d6abf7a22bc2df8cacbf99.tar.xz
nixpkgs-089eef511c7e865867d6abf7a22bc2df8cacbf99.tar.zst
nixpkgs-089eef511c7e865867d6abf7a22bc2df8cacbf99.zip
* Module aggregator: use buildEnv, which is much faster because it
  creates symlinks lazily (i.e., it creates a single symlink to an
  entire tree unless another input has an overlapping tree).  As a
  result it creates only a few dozen symlinks instead of ~ 12000
  (which can take almost 2 minutes on my laptop).

svn path=/nixpkgs/branches/stdenv-updates/; revision=15200
Diffstat (limited to 'pkgs/os-specific/linux/module-init-tools/aggregator.nix')
-rw-r--r--pkgs/os-specific/linux/module-init-tools/aggregator.nix47
1 files changed, 23 insertions, 24 deletions
diff --git a/pkgs/os-specific/linux/module-init-tools/aggregator.nix b/pkgs/os-specific/linux/module-init-tools/aggregator.nix
index f11642b9a68..cc4e6ab3552 100644
--- a/pkgs/os-specific/linux/module-init-tools/aggregator.nix
+++ b/pkgs/os-specific/linux/module-init-tools/aggregator.nix
@@ -1,28 +1,27 @@
-{stdenv, module_init_tools, modules}:
+{stdenv, module_init_tools, modules, buildEnv}:
 
-stdenv.mkDerivation {
+buildEnv {
   name = "kernel-modules";
 
-  buildCommand = ''
-    ensureDir $out/lib/modules
-    cd $out/
-    modules="${toString modules}"
-    for i in $modules; do 
-        cp -rfs $i/* .
-        chmod -R u+w .
-        v=$(cd $i/lib/modules && ls -d *)
-        if test -n "$version" -a "$v" != "$version"; then
-            echo "kernel version mismatch: $version versus $v (in the module paths $modules)";
-            exit 1
-        fi
-        version=$v
-    done
-    echo "kernel version is $version"
-    rm -rf nix-support
-    cd lib/modules/
-    rm */modules.*
-    #  linux-* will pass the new kernel version to depmod to take rather than `uname -r` (see man page)
-    MODULE_DIR=$PWD/ ${module_init_tools}/sbin/depmod -a $(basename lib/modules/2.*)
-    cd $out/
-  '';
+  paths = modules;
+
+  postBuild =
+    ''
+      source ${stdenv}/setup
+    
+      kernelVersion=$(cd $out/lib/modules && ls -d *)
+      if test "$(echo $kernelVersion | wc -w)" != 1; then
+         echo "inconsistent kernel versions: $kernelVersion"
+         exit 1
+      fi
+    
+      echo "kernel version is $kernelVersion"
+
+      # Regenerate the depmod map files.  Be sure to pass an explicit
+      # kernel version number, otherwise depmod will use `uname -r'.
+      if test -w $out/lib/modules/$kernelVersion; then
+          rm -f $out/lib/modules/$kernelVersion/modules.*
+          MODULE_DIR=$out/lib/modules/ ${module_init_tools}/sbin/depmod -a $kernelVersion
+      fi
+    '';
 }