nixpkgs/pkgs/os-specific/linux/klibc/default.nix
John Ericson 8929989614 lib: Clean up how linux and gcc config is specified
The `platform` field is pointless nesting: it's just stuff that happens
to be defined together, and that should be an implementation detail.

This instead makes `linux-kernel` and `gcc` top level fields in platform
configs. They join `rustc` there [all are optional], which was put there
and not in `platform` in anticipation of a change like this.

`linux-kernel.arch` in particular also becomes `linuxArch`, to match the
other `*Arch`es.

The next step after is this to combine the *specific* machines from
`lib.systems.platforms` with `lib.systems.examples`, keeping just the
"multiplatform" ones for defaulting.
2021-01-21 22:44:09 -05:00

54 lines
1.5 KiB
Nix

{ lib, stdenv, fetchurl, buildPackages, linuxHeaders, perl }:
let
commonMakeFlags = [
"prefix=$(out)"
"SHLIBDIR=$(out)/lib"
];
in
stdenv.mkDerivation rec {
pname = "klibc";
version = "2.0.8";
src = fetchurl {
url = "mirror://kernel/linux/libs/klibc/2.0/klibc-${version}.tar.xz";
sha256 = "0dmlkhnn5q8fc6rkzsisir4chkzmmiq6xkjmvyvf0g7yihwz2j2f";
};
patches = [ ./no-reinstall-kernel-headers.patch ];
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ perl ];
strictDeps = true;
hardeningDisable = [ "format" "stackprotector" ];
makeFlags = commonMakeFlags ++ [
"KLIBCARCH=${stdenv.hostPlatform.linuxArch}"
"KLIBCKERNELSRC=${linuxHeaders}"
] # TODO(@Ericson2314): We now can get the ABI from
# `stdenv.hostPlatform.parsed.abi`, is this still a good idea?
++ lib.optional (stdenv.hostPlatform.linuxArch == "arm") "CONFIG_AEABI=y"
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "CROSS_COMPILE=${stdenv.cc.targetPrefix}";
# Install static binaries as well.
postInstall = ''
dir=$out/lib/klibc/bin.static
mkdir $dir
cp $(find $(find . -name static) -type f ! -name "*.g" -a ! -name ".*") $dir/
for file in ${linuxHeaders}/include/*; do
ln -sv $file $out/lib/klibc/include
done
'';
meta = {
description = "Minimalistic libc subset for initramfs usage";
homepage = "https://kernel.org/pub/linux/libs/klibc/";
maintainers = with lib.maintainers; [ fpletz ];
license = lib.licenses.bsd3;
platforms = lib.platforms.linux;
};
}