2017-07-09 20:12:32 +01:00
|
|
|
{ stdenvNoCC, lib, buildPackages
|
|
|
|
, buildPlatform, hostPlatform
|
|
|
|
, fetchurl, perl
|
|
|
|
}:
|
2016-05-14 08:13:46 +01:00
|
|
|
|
2017-07-09 20:12:32 +01:00
|
|
|
assert hostPlatform.isLinux;
|
2016-05-14 08:13:46 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
version = "4.4.10";
|
2017-07-09 20:12:32 +01:00
|
|
|
inherit (hostPlatform.platform) kernelHeadersBaseConfig;
|
2016-05-14 08:13:46 +01:00
|
|
|
in
|
|
|
|
|
2017-07-09 20:12:32 +01:00
|
|
|
stdenvNoCC.mkDerivation {
|
2016-05-14 08:13:46 +01:00
|
|
|
name = "linux-headers-${version}";
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";
|
|
|
|
sha256 = "1kpjvvd9q9wwr3314q5ymvxii4dv2d27295bzly225wlc552xhja";
|
|
|
|
};
|
|
|
|
|
2017-07-09 20:12:32 +01:00
|
|
|
targetConfig = if hostPlatform != buildPlatform then hostPlatform.config else null;
|
2016-05-14 08:13:46 +01:00
|
|
|
|
2017-09-15 00:24:48 +01:00
|
|
|
platform = hostPlatform.platform.kernelArch;
|
2016-05-14 08:13:46 +01:00
|
|
|
|
2017-07-09 20:12:32 +01:00
|
|
|
# It may look odd that we use `stdenvNoCC`, and yet explicit depend on a cc.
|
|
|
|
# We do this so we have a build->build, not build->host, C compiler.
|
2017-06-26 04:10:03 +01:00
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
|
|
|
nativeBuildInputs = [ perl ];
|
2016-05-14 08:13:46 +01:00
|
|
|
|
2017-07-09 20:12:32 +01:00
|
|
|
extraIncludeDirs = lib.optional hostPlatform.isPowerPC ["ppc"];
|
2016-05-14 08:13:46 +01:00
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
if test -n "$targetConfig"; then
|
|
|
|
export ARCH=$platform
|
|
|
|
fi
|
|
|
|
make ${kernelHeadersBaseConfig} SHELL=bash
|
|
|
|
make mrproper headers_check SHELL=bash
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
make INSTALL_HDR_PATH=$out headers_install
|
|
|
|
|
|
|
|
# Some builds (e.g. KVM) want a kernel.release.
|
|
|
|
mkdir -p $out/include/config
|
|
|
|
echo "${version}-default" > $out/include/config/kernel.release
|
|
|
|
'';
|
|
|
|
|
|
|
|
# !!! hacky
|
|
|
|
fixupPhase = ''
|
|
|
|
ln -s asm $out/include/asm-$platform
|
|
|
|
if test "$platform" = "i386" -o "$platform" = "x86_64"; then
|
|
|
|
ln -s asm $out/include/asm-x86
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
2017-07-09 20:12:32 +01:00
|
|
|
meta = with lib; {
|
2016-05-14 08:13:46 +01:00
|
|
|
description = "Header files and scripts for Linux kernel";
|
|
|
|
license = licenses.gpl2;
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|