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 }: 1 + { stdenvNoCC, lib, buildPackages 2 + , buildPlatform, hostPlatform 3 + , fetchurl, perl 4 + }: 2 5 3 - assert cross == null -> stdenv.isLinux; 6 + assert hostPlatform.isLinux; 4 7 5 8 let 6 - 7 9 version = "4.4.10"; 8 - 9 - kernelHeadersBaseConfig = 10 - if cross == null 11 - then stdenv.platform.kernelHeadersBaseConfig 12 - else cross.platform.kernelHeadersBaseConfig; 13 - 10 + inherit (hostPlatform.platform) kernelHeadersBaseConfig; 14 11 in 15 12 16 - stdenv.mkDerivation { 13 + stdenvNoCC.mkDerivation { 17 14 name = "linux-headers-${version}"; 18 15 19 16 src = fetchurl { ··· 21 18 sha256 = "1kpjvvd9q9wwr3314q5ymvxii4dv2d27295bzly225wlc552xhja"; 22 19 }; 23 20 24 - targetConfig = if cross != null then cross.config else null; 21 + targetConfig = if hostPlatform != buildPlatform then hostPlatform.config else null; 25 22 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"; 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"); 34 29 35 - buildInputs = [perl]; 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 ]; 36 33 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 []; 34 + extraIncludeDirs = lib.optional hostPlatform.isPowerPC ["ppc"]; 41 35 42 36 buildPhase = '' 43 37 if test -n "$targetConfig"; then ··· 63 57 fi 64 58 ''; 65 59 66 - meta = with stdenv.lib; { 60 + meta = with lib; { 67 61 description = "Header files and scripts for Linux kernel"; 68 62 license = licenses.gpl2; 69 63 platforms = platforms.linux;
+1 -4
pkgs/top-level/all-packages.nix
··· 12021 12021 12022 12022 lkl = callPackage ../applications/virtualization/lkl { }; 12023 12023 12024 - linuxHeaders_4_4 = callPackage ../os-specific/linux/kernel-headers/4.4.nix { 12025 - cross = if targetPlatform != hostPlatform then targetPlatform else null; 12026 - }; 12024 + linuxHeaders_4_4 = callPackage ../os-specific/linux/kernel-headers/4.4.nix { }; 12027 12025 linuxHeaders = linuxHeaders_4_4; 12028 12026 12029 12027 kernelPatches = callPackage ../os-specific/linux/kernel/patches.nix { }; ··· 12666 12664 uclibc = callPackage ../os-specific/linux/uclibc { }; 12667 12665 12668 12666 uclibcCross = lowPrio (callPackage ../os-specific/linux/uclibc { 12669 - inherit (buildPackages) linuxHeaders; 12670 12667 gccCross = gccCrossStageStatic; 12671 12668 cross = assert targetPlatform != buildPlatform; targetPlatform; 12672 12669 });