Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at fix-function-merge 59 lines 1.8 kB view raw
1{ lib, stdenv, fetchurl, buildPackages, linuxHeaders, perl, nixosTests }: 2 3let 4 commonMakeFlags = [ 5 "prefix=$(out)" 6 "SHLIBDIR=$(out)/lib" 7 ]; 8in 9 10stdenv.mkDerivation rec { 11 pname = "klibc"; 12 version = "2.0.13"; 13 14 src = fetchurl { 15 url = "mirror://kernel/linux/libs/klibc/2.0/klibc-${version}.tar.xz"; 16 hash = "sha256-1nOilPdC1ZNoIi/1w4Ri2BCYxVBjeZ3m+4p7o9SvBDY="; 17 }; 18 19 patches = [ ./no-reinstall-kernel-headers.patch ]; 20 21 depsBuildBuild = [ buildPackages.stdenv.cc ]; 22 nativeBuildInputs = [ perl ]; 23 strictDeps = true; 24 25 hardeningDisable = [ "format" "stackprotector" ]; 26 27 makeFlags = commonMakeFlags ++ [ 28 "KLIBCARCH=${if stdenv.hostPlatform.isRiscV64 then "riscv64" else stdenv.hostPlatform.linuxArch}" 29 "KLIBCKERNELSRC=${linuxHeaders}" 30 ] # TODO(@Ericson2314): We now can get the ABI from 31 # `stdenv.hostPlatform.parsed.abi`, is this still a good idea? 32 ++ lib.optional (stdenv.hostPlatform.linuxArch == "arm") "CONFIG_AEABI=y" 33 ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "CROSS_COMPILE=${stdenv.cc.targetPrefix}"; 34 35 # Install static binaries as well. 36 postInstall = '' 37 dir=$out/lib/klibc/bin.static 38 mkdir $dir 39 cp $(find $(find . -name static) -type f ! -name "*.g" -a ! -name ".*") $dir/ 40 41 for file in ${linuxHeaders}/include/*; do 42 ln -sv $file $out/lib/klibc/include 43 done 44 ''; 45 46 passthru.tests = { 47 # uses klibc's ipconfig 48 inherit (nixosTests) initrd-network-ssh; 49 }; 50 51 meta = { 52 description = "Minimalistic libc subset for initramfs usage"; 53 mainProgram = "klcc"; 54 homepage = "https://kernel.org/pub/linux/libs/klibc/"; 55 maintainers = with lib.maintainers; [ fpletz ]; 56 license = lib.licenses.bsd3; 57 platforms = lib.platforms.linux; 58 }; 59}