linux-headers: Improve derivation, removing cross arg

- Perl is used at build time, so must be in `nativeBuildInputs`. It's
not used at run time so it should not be in `buildInputs`, too.

- Don't treat headers like a compiler---use the build and host
platforms not host and target. Perhaps that would make sense if every
library's headers could be a separate derivation, but since that is
not feasible, best to keep the implementation and interface in the
same stage.

To do this, we used `stdenvNoCC` to get rid of the normal toolchain,
and added a dependency for the toolchain targeting the build platform
--- `buildPackages.stdenv.cc` --- thus everything is effectively slid
a stage black.

+20 -29
+19 -25
pkgs/os-specific/linux/kernel-headers/4.4.nix
··· 1 - { stdenv, fetchurl, perl, cross ? null }: 2 3 - assert cross == null -> stdenv.isLinux; 4 5 let 6 - 7 version = "4.4.10"; 8 - 9 - kernelHeadersBaseConfig = 10 - if cross == null 11 - then stdenv.platform.kernelHeadersBaseConfig 12 - else cross.platform.kernelHeadersBaseConfig; 13 - 14 in 15 16 - stdenv.mkDerivation { 17 name = "linux-headers-${version}"; 18 19 src = fetchurl { ··· 21 sha256 = "1kpjvvd9q9wwr3314q5ymvxii4dv2d27295bzly225wlc552xhja"; 22 }; 23 24 - targetConfig = if cross != null then cross.config else null; 25 26 - platform = 27 - if cross != null then cross.platform.kernelArch else 28 - if stdenv.system == "i686-linux" then "i386" else 29 - if stdenv.system == "x86_64-linux" then "x86_64" else 30 - if stdenv.system == "powerpc-linux" then "powerpc" else 31 - if stdenv.isArm then "arm" else 32 - if stdenv.platform ? kernelArch then stdenv.platform.kernelArch else 33 - abort "don't know what the kernel include directory is called for this platform"; 34 35 - buildInputs = [perl]; 36 37 - extraIncludeDirs = 38 - if cross != null then 39 - (if cross.arch == "powerpc" then ["ppc"] else []) 40 - else if stdenv.system == "powerpc-linux" then ["ppc"] else []; 41 42 buildPhase = '' 43 if test -n "$targetConfig"; then ··· 63 fi 64 ''; 65 66 - meta = with stdenv.lib; { 67 description = "Header files and scripts for Linux kernel"; 68 license = licenses.gpl2; 69 platforms = platforms.linux;
··· 1 + { stdenvNoCC, lib, buildPackages 2 + , buildPlatform, hostPlatform 3 + , fetchurl, perl 4 + }: 5 6 + assert hostPlatform.isLinux; 7 8 let 9 version = "4.4.10"; 10 + inherit (hostPlatform.platform) kernelHeadersBaseConfig; 11 in 12 13 + stdenvNoCC.mkDerivation { 14 name = "linux-headers-${version}"; 15 16 src = fetchurl { ··· 18 sha256 = "1kpjvvd9q9wwr3314q5ymvxii4dv2d27295bzly225wlc552xhja"; 19 }; 20 21 + targetConfig = if hostPlatform != buildPlatform then hostPlatform.config else null; 22 23 + platform = hostPlatform.platform.kernelArch or ( 24 + if hostPlatform.system == "i686-linux" then "i386" else 25 + if hostPlatform.system == "x86_64-linux" then "x86_64" else 26 + if hostPlatform.system == "powerpc-linux" then "powerpc" else 27 + if hostPlatform.isArm then "arm" else 28 + abort "don't know what the kernel include directory is called for this platform"); 29 30 + # It may look odd that we use `stdenvNoCC`, and yet explicit depend on a cc. 31 + # We do this so we have a build->build, not build->host, C compiler. 32 + nativeBuildInputs = [ buildPackages.stdenv.cc perl ]; 33 34 + extraIncludeDirs = lib.optional hostPlatform.isPowerPC ["ppc"]; 35 36 buildPhase = '' 37 if test -n "$targetConfig"; then ··· 57 fi 58 ''; 59 60 + meta = with lib; { 61 description = "Header files and scripts for Linux kernel"; 62 license = licenses.gpl2; 63 platforms = platforms.linux;
+1 -4
pkgs/top-level/all-packages.nix
··· 12021 12022 lkl = callPackage ../applications/virtualization/lkl { }; 12023 12024 - linuxHeaders_4_4 = callPackage ../os-specific/linux/kernel-headers/4.4.nix { 12025 - cross = if targetPlatform != hostPlatform then targetPlatform else null; 12026 - }; 12027 linuxHeaders = linuxHeaders_4_4; 12028 12029 kernelPatches = callPackage ../os-specific/linux/kernel/patches.nix { }; ··· 12666 uclibc = callPackage ../os-specific/linux/uclibc { }; 12667 12668 uclibcCross = lowPrio (callPackage ../os-specific/linux/uclibc { 12669 - inherit (buildPackages) linuxHeaders; 12670 gccCross = gccCrossStageStatic; 12671 cross = assert targetPlatform != buildPlatform; targetPlatform; 12672 });
··· 12021 12022 lkl = callPackage ../applications/virtualization/lkl { }; 12023 12024 + linuxHeaders_4_4 = callPackage ../os-specific/linux/kernel-headers/4.4.nix { }; 12025 linuxHeaders = linuxHeaders_4_4; 12026 12027 kernelPatches = callPackage ../os-specific/linux/kernel/patches.nix { }; ··· 12664 uclibc = callPackage ../os-specific/linux/uclibc { }; 12665 12666 uclibcCross = lowPrio (callPackage ../os-specific/linux/uclibc { 12667 gccCross = gccCrossStageStatic; 12668 cross = assert targetPlatform != buildPlatform; targetPlatform; 12669 });