nixpkgs/pkgs/os-specific/linux/klibc/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
1.7 KiB
Nix
Raw Normal View History

2022-12-02 10:29:26 +00:00
{ lib, stdenv, fetchurl, buildPackages, linuxHeaders, perl, nixosTests }:
let
commonMakeFlags = [
"prefix=$(out)"
"SHLIBDIR=$(out)/lib"
];
in
stdenv.mkDerivation rec {
pname = "klibc";
2023-10-10 14:13:28 +00:00
version = "2.0.13";
src = fetchurl {
url = "mirror://kernel/linux/libs/klibc/2.0/klibc-${version}.tar.xz";
2023-10-10 14:13:28 +00:00
hash = "sha256-1nOilPdC1ZNoIi/1w4Ri2BCYxVBjeZ3m+4p7o9SvBDY=";
};
patches = [ ./no-reinstall-kernel-headers.patch ];
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ perl ];
2021-01-17 15:30:57 +00:00
strictDeps = true;
hardeningDisable = [ "format" "stackprotector" ];
makeFlags = commonMakeFlags ++ [
2022-09-05 22:51:51 +00:00
"KLIBCARCH=${if stdenv.hostPlatform.isRiscV64 then "riscv64" else stdenv.hostPlatform.linuxArch}"
"KLIBCKERNELSRC=${linuxHeaders}"
2017-06-28 20:38:33 +00:00
] # 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"
2021-01-15 14:45:37 +00:00
++ 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
'';
2022-12-02 10:29:26 +00:00
passthru.tests = {
# uses klibc's ipconfig
inherit (nixosTests) initrd-network-ssh;
};
meta = {
2020-02-08 13:30:51 +00:00
description = "Minimalistic libc subset for initramfs usage";
mainProgram = "klcc";
2020-02-08 13:30:51 +00:00
homepage = "https://kernel.org/pub/linux/libs/klibc/";
maintainers = with lib.maintainers; [ fpletz ];
license = lib.licenses.bsd3;
platforms = lib.platforms.linux;
};
}