From 0bdd926a32658fa8b6481dc388968862c6e9c427 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sat, 2 Mar 2013 09:53:56 -0500 Subject: [PATCH] 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. --- .../linux/kernel/manual-config.nix | 34 ++++++++++++------- pkgs/top-level/all-packages.nix | 4 +-- 2 files changed, 24 insertions(+), 14 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; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1fb24e19ef2..2ccd00e8ad1 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6013,7 +6013,7 @@ let callPackage = newScope self; self = { - inherit kernel; + kernel = kernel.dev or kernel; acpi_call = callPackage ../os-specific/linux/acpi-call {}; @@ -6115,7 +6115,7 @@ let zfs = callPackage ../os-specific/linux/zfs/default.nix { }; }; - in self; + in (self // { kernel = self.kernel.out; }); # Build the kernel modules for the some of the kernels. linuxPackages_2_6_32 = recurseIntoAttrs (linuxPackagesFor linux_2_6_32);