From 089eef511c7e865867d6abf7a22bc2df8cacbf99 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 20 Apr 2009 19:13:40 +0000 Subject: [PATCH] * 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 --- .../linux/module-init-tools/aggregator.nix | 47 +++++++++---------- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/pkgs/os-specific/linux/module-init-tools/aggregator.nix b/pkgs/os-specific/linux/module-init-tools/aggregator.nix index f11642b9a68f..cc4e6ab35521 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 + ''; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4c801de2e956..3c8467aedd57 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7313,7 +7313,7 @@ let aggregateModules = modules: import ../os-specific/linux/module-init-tools/aggregator.nix { - inherit stdenv module_init_tools modules; + inherit stdenv module_init_tools modules buildEnv; }; modutils = import ../os-specific/linux/modutils {