about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/kernel/generic.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/os-specific/linux/kernel/generic.nix')
-rw-r--r--pkgs/os-specific/linux/kernel/generic.nix18
1 files changed, 16 insertions, 2 deletions
diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix
index ce609f2384993..a86aef1af8e3c 100644
--- a/pkgs/os-specific/linux/kernel/generic.nix
+++ b/pkgs/os-specific/linux/kernel/generic.nix
@@ -6,6 +6,9 @@
 , # The kernel version.
   version
 
+, # The version number used for the module directory
+  modDirVersion ? version
+
 , # The kernel configuration.
   config
 
@@ -35,6 +38,7 @@
 , extraMeta ? {}
 , ubootChooser ? null
 , postInstall ? ""
+, setModuleDir ? true
 
 , # After the builder did a 'make all' (kernel + modules)
   # we force building the target asked: bzImage/zImage/uImage/...
@@ -65,7 +69,7 @@ stdenv.mkDerivation {
   enableParallelBuilding = true;
 
   passthru = {
-    inherit version;
+    inherit version modDirVersion;
     # Combine the `features' attribute sets of all the kernel patches.
     features = lib.fold (x: y: (if x ? features then x.features else {}) // y) features kernelPatches;
   };
@@ -74,7 +78,16 @@ stdenv.mkDerivation {
 
   generateConfig = ./generate-config.pl;
 
-  inherit preConfigure src module_init_tools localVersion postBuild postInstall;
+  inherit preConfigure src module_init_tools localVersion postInstall;
+
+  #Currently, the builder sets $MODULE_DIR during installPhase. This causes
+  #problems with at least linux 3.0, so we need to conditionally avoid
+  #setting $MODULE_DIR. This prepend to postBuild accomplishes this with a
+  #sed/eval trick thanks to MarcWeber
+
+  postBuild = (if setModuleDir then "" else '' 
+    eval "$(type installPhase | sed -e '1d' -e '/export MODULE_DIR/d')";
+  '') + postBuild;
 
   patches = map (p: p.patch) kernelPatches;
 
@@ -140,3 +153,4 @@ stdenv.mkDerivation {
     platforms = lib.platforms.linux;
   } // extraMeta;
 }
+