summary refs log tree commit diff
path: root/pkgs/os-specific/linux/kernel/manual-config.nix
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2013-03-02 09:53:56 -0500
committerShea Levy <shea@shealevy.com>2013-03-02 09:54:08 -0500
commit0bdd926a32658fa8b6481dc388968862c6e9c427 (patch)
tree98c6f78bcead6dcd0ee7dc57beb23b69d72b49e0 /pkgs/os-specific/linux/kernel/manual-config.nix
parent5d952411c600d9d9794c222f109ca934f712a567 (diff)
downloadnixpkgs-0bdd926a32658fa8b6481dc388968862c6e9c427.tar
nixpkgs-0bdd926a32658fa8b6481dc388968862c6e9c427.tar.gz
nixpkgs-0bdd926a32658fa8b6481dc388968862c6e9c427.tar.bz2
nixpkgs-0bdd926a32658fa8b6481dc388968862c6e9c427.tar.lz
nixpkgs-0bdd926a32658fa8b6481dc388968862c6e9c427.tar.xz
nixpkgs-0bdd926a32658fa8b6481dc388968862c6e9c427.tar.zst
nixpkgs-0bdd926a32658fa8b6481dc388968862c6e9c427.zip
linux/manual-config: put build and source trees into a separate 'dev' output.
This makes it possible to still build out-of-tree modules without making a system using this kernel depend on the full source and build tree at runtime.

Note that references to the source tree are removed from kernel modules after build.
Ideally, this would be accomplished by modifying the Makefile that puts the reference there in the first place, but I haven't tracked that down yet.
Diffstat (limited to 'pkgs/os-specific/linux/kernel/manual-config.nix')
-rw-r--r--pkgs/os-specific/linux/kernel/manual-config.nix34
1 files changed, 22 insertions, 12 deletions
diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix
index 28abd434b05..2191cc046e4 100644
--- a/pkgs/os-specific/linux/kernel/manual-config.nix
+++ b/pkgs/os-specific/linux/kernel/manual-config.nix
@@ -75,16 +75,6 @@ let
     "INSTALL_PATH=$(out)"
   ] ++ (optional isModular "INSTALL_MOD_PATH=$(out)")
   ++ optional installsFirmware "INSTALL_FW_PATH=$(out)/lib/firmware";
-in
-
-stdenv.mkDerivation {
-  name = "linux-${version}";
-
-  enableParallelBuilding = true;
-
-  passthru = {
-    inherit version modDirVersion config kernelPatches src;
-  };
 
   sourceRoot = stdenv.mkDerivation {
     name = "linux-${version}-source";
@@ -108,11 +98,25 @@ stdenv.mkDerivation {
       mv $sourceRoot $out
     '';
   };
+in
+
+stdenv.mkDerivation {
+  name = "linux-${version}";
+
+  enableParallelBuilding = true;
+
+  outputs = if isModular then [ "out" "dev" ] else null;
+
+  passthru = {
+    inherit version modDirVersion config kernelPatches src;
+  };
+
+  inherit sourceRoot;
 
   unpackPhase = ''
     mkdir build
     export buildRoot="$(pwd)/build"
-    cd $sourceRoot
+    cd ${sourceRoot}
   '';
 
   configurePhase = ''
@@ -140,7 +144,9 @@ stdenv.mkDerivation {
     make modules_install $makeFlags "''${makeFlagsArray[@]}" \
       $installFlags "''${installFlagsArray[@]}"
     rm -f $out/lib/modules/${modDirVersion}/build
-    mv $buildRoot $out/lib/modules/${modDirVersion}/build
+    mkdir -p $dev/lib/modules/${modDirVersion}
+    mv $out/lib/modules/${modDirVersion}/source $dev/lib/modules/${modDirVersion}/source
+    mv $buildRoot $dev/lib/modules/${modDirVersion}/build
   '' else optionalString installsFirmware ''
     make firmware_install $makeFlags "''${makeFlagsArray[@]}" \
       $installFlags "''${installFlagsArray[@]}"
@@ -149,6 +155,10 @@ stdenv.mkDerivation {
   postFixup = if isModular then ''
     if [ -z "$dontStrip" ]; then
         find $out -name "*.ko" -print0 | xargs -0 -r strip -S
+        # Remove all references to the source directory to avoid unneeded
+        # runtime dependencies
+        find $out -name "*.ko" -print0 | xargs -0 -r sed -i \
+          "s|${sourceRoot}|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${sourceRoot.name}|g"
     fi
   '' else null;