at 22.05-pre 53 lines 1.6 kB view raw
1{ lib, stdenv, fetchurl, buildPackages, linuxHeaders, perl }: 2 3let 4 commonMakeFlags = [ 5 "prefix=$(out)" 6 "SHLIBDIR=$(out)/lib" 7 ]; 8in 9 10stdenv.mkDerivation rec { 11 pname = "klibc"; 12 version = "2.0.9"; 13 14 src = fetchurl { 15 url = "mirror://kernel/linux/libs/klibc/2.0/klibc-${version}.tar.xz"; 16 sha256 = "sha256-bcynCJEzINJjCfBbDCv2gHG/EbPa3MTmx9kjg3/CPuE="; 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=${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 meta = { 47 description = "Minimalistic libc subset for initramfs usage"; 48 homepage = "https://kernel.org/pub/linux/libs/klibc/"; 49 maintainers = with lib.maintainers; [ fpletz ]; 50 license = lib.licenses.bsd3; 51 platforms = lib.platforms.linux; 52 }; 53}