mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-08-27 02:34:53 +00:00
Currently, you need to override `stdenv.hostPlatform` to request a compressed kernel on AArch64, and the kernel configuration is split between the central structured configuration and string snippets in platform definitions. This has consequently made the latter bitrot terribly. Since the platform‐specific logic is now very limited after cleaning up the detritus, we can move it into the kernel derivation and expose the relevant configuration there for anyone who wants to customize it further or needs to read it out. Co-authored-by: zowoq <59103226+zowoq@users.noreply.github.com>
40 lines
1.7 KiB
Nix
40 lines
1.7 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
buildPackages,
|
|
extraMakeFlags ? [ ],
|
|
}:
|
|
# Absolute paths for compilers avoid any PATH-clobbering issues.
|
|
[
|
|
#
|
|
# We use the unwrapped compiler, because the clang-wrapper doesn't like -target.
|
|
"CC=${lib.getExe stdenv.cc.cc}"
|
|
# The wrapper for ld.lld breaks linking the kernel. We use the unwrapped linker as workaround. See:
|
|
# https://github.com/NixOS/nixpkgs/issues/321667
|
|
"LD=${lib.getExe' stdenv.cc.bintools.bintools "${stdenv.cc.targetPrefix}ld"}"
|
|
"AR=${lib.getExe' stdenv.cc "${stdenv.cc.targetPrefix}ar"}"
|
|
"NM=${lib.getExe' stdenv.cc "${stdenv.cc.targetPrefix}nm"}"
|
|
"STRIP=${lib.getExe' stdenv.cc.bintools.bintools "${stdenv.cc.targetPrefix}strip"}"
|
|
"OBJCOPY=${lib.getExe' stdenv.cc "${stdenv.cc.targetPrefix}objcopy"}"
|
|
"OBJDUMP=${lib.getExe' stdenv.cc "${stdenv.cc.targetPrefix}objdump"}"
|
|
"READELF=${lib.getExe' stdenv.cc "${stdenv.cc.targetPrefix}readelf"}"
|
|
"HOSTCC=${lib.getExe' buildPackages.stdenv.cc "${buildPackages.stdenv.cc.targetPrefix}cc"}"
|
|
"HOSTCXX=${lib.getExe' buildPackages.stdenv.cc "${buildPackages.stdenv.cc.targetPrefix}c++"}"
|
|
"HOSTAR=${lib.getExe' buildPackages.stdenv.cc.bintools "${buildPackages.stdenv.cc.targetPrefix}ar"}"
|
|
"HOSTLD=${lib.getExe' buildPackages.stdenv.cc.bintools "${buildPackages.stdenv.cc.targetPrefix}ld"}"
|
|
"ARCH=${stdenv.hostPlatform.linuxArch}"
|
|
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
|
|
]
|
|
# Add the built in headers the kernel needs
|
|
++ lib.optionals (stdenv.cc.isClang) (
|
|
let
|
|
clangLib = lib.getLib stdenv.cc.cc;
|
|
majorVer = lib.versions.major clangLib.version;
|
|
in
|
|
[
|
|
"CFLAGS_MODULE=-I${clangLib}/lib/clang/${majorVer}/include"
|
|
"CFLAGS_KERNEL=-I${clangLib}/lib/clang/${majorVer}/include"
|
|
]
|
|
)
|
|
++ extraMakeFlags
|