diff options
author | Shea Levy <shea@shealevy.com> | 2012-08-11 21:02:09 -0400 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2012-08-11 21:02:30 -0400 |
commit | 0c18551c93d1d9f8555fadc8edbc460d1493a889 (patch) | |
tree | ebe301711e54dd6c0f60cfeaf5331e5d87552b0c /pkgs | |
parent | 0dea12ff8d7b210d735b5d555c67008f40983f82 (diff) | |
download | nixlib-0c18551c93d1d9f8555fadc8edbc460d1493a889.tar nixlib-0c18551c93d1d9f8555fadc8edbc460d1493a889.tar.gz nixlib-0c18551c93d1d9f8555fadc8edbc460d1493a889.tar.bz2 nixlib-0c18551c93d1d9f8555fadc8edbc460d1493a889.tar.lz nixlib-0c18551c93d1d9f8555fadc8edbc460d1493a889.tar.xz nixlib-0c18551c93d1d9f8555fadc8edbc460d1493a889.tar.zst nixlib-0c18551c93d1d9f8555fadc8edbc460d1493a889.zip |
linux/manual-config: Do source unpacking/patching in a separate derivation.
Since we keep the source in the kernel build anyway, no space is wasted by having a separate store path for the unpacked source. The upside is that the same source can be used to build the kernel multiple times, or generate configurations for later kernel builds, without going through the (fairly long) unpack and patch process multiple times.
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/os-specific/linux/kernel/manual-config.nix | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index f9806c45451a..aa00bd2786a5 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -74,40 +74,58 @@ let (isModular || (config.isDisabled "FIRMWARE_IN_KERNEL")); commonMakeFlags = [ - "O=../build" + "O=$(buildRoot)" "INSTALL_PATH=$(out)" ] ++ (optional isModular "INSTALL_MOD_PATH=$(out)") ++ optional installsFirmware "INSTALL_FW_PATH=$(out)/lib/firmware"; in -stdenv.mkDerivation { +let self = stdenv.mkDerivation { name = "linux-${version}"; enableParallelBuilding = true; passthru = { - inherit version modDirVersion config kernelPatches; - }; + inherit version modDirVersion config kernelPatches src; + + source = stdenv.mkDerivation { + name = "linux-${version}-source"; + + inherit src; - inherit src; + patches = map (p: p.patch) kernelPatches; - patches = map (p: p.patch) kernelPatches; + phases = [ "unpackPhase" "patchPhase" "installPhase" ]; + + prePatch = '' + for mf in $(find -name Makefile -o -name Makefile.include -o -name install.sh); do + echo "stripping FHS paths in \`$mf'..." + sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g ; s|/sbin/||g' + done + sed -i Makefile -e 's|= depmod|= ${kmod}/sbin/depmod|' + ''; + + installPhase = '' + cd .. + mv $sourceRoot $out + ''; + }; + }; - prePatch = '' - for mf in $(find -name Makefile -o -name Makefile.include -o -name install.sh); do - echo "stripping FHS paths in \`$mf'..." - sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g ; s|/sbin/||g' - done - sed -i Makefile -e 's|= depmod|= ${kmod}/sbin/depmod|' + unpackPhase = '' + ln -sv ${self.source} src + export sourceRoot="$(pwd)/src" + mkdir build + export buildRoot="$(pwd)/build" + cd $sourceRoot ''; configurePhase = '' runHook preConfigure - mkdir ../build make $makeFlags "''${makeFlagsArray[@]}" mrproper - ln -sv ${configfile} ../build/.config + ln -sv ${configfile} $buildRoot/.config make $makeFlags "''${makeFlagsArray[@]}" oldconfig - rm ../build/.config.old + rm $buildRoot/.config.old runHook postConfigure ''; @@ -131,9 +149,9 @@ stdenv.mkDerivation { rm -f $out/lib/modules/${modDirVersion}/{build,source} cd .. mv $sourceRoot $out/lib/modules/${modDirVersion}/source - mv build $out/lib/modules/${modDirVersion}/build + mv $buildRoot $out/lib/modules/${modDirVersion}/build unlink $out/lib/modules/${modDirVersion}/build/source - ln -sv $out/lib/modules/${modDirVersion}/{,build/}source + ln -sv ${self.source} $out/lib/modules/${modDirVersion}/build/source '' else optionalString installsFirmware '' make firmware_install $makeFlags "''${makeFlagsArray[@]}" \ $installFlags "''${installFlagsArray[@]}" @@ -154,4 +172,4 @@ stdenv.mkDerivation { ]; platforms = lib.platforms.linux; }; -} +}; in self |