at master 2.4 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchpatch, 5 callPackage, 6 cmake, 7 ninja, 8 swift, 9 Dispatch, 10 icu, 11 libxml2, 12 curl, 13}: 14 15let 16 sources = callPackage ../sources.nix { }; 17in 18stdenv.mkDerivation { 19 pname = "swift-corelibs-foundation"; 20 21 inherit (sources) version; 22 src = sources.swift-corelibs-foundation; 23 24 patches = [ 25 # from https://github.com/apple/swift-corelibs-foundation/pull/4811 26 # fix build with glibc >=2.38 27 (fetchpatch { 28 url = "https://github.com/apple/swift-corelibs-foundation/commit/47260803a108c6e0d639adcebeed3ac6a76e8bcd.patch"; 29 hash = "sha256-1JUSQW86IHKkBZqxvpk0P8zcSKntzOTNlMoGBfgeT4c="; 30 }) 31 32 # Fix the build with modern Clang. 33 (fetchpatch { 34 url = "https://github.com/swiftlang/swift-corelibs-foundation/commit/76058114e5f5b47e02dd4441a6389858bb599bd6.patch"; 35 hash = "sha256-N/hdTGCWMz092xh3AI28v3b+zjQHRmsb1F/2Q2u/jik="; 36 }) 37 (fetchpatch { 38 url = "https://github.com/swiftlang/swift-corelibs-foundation/commit/5f3e896e522ff364780e6330df867e20e26269b4.patch"; 39 hash = "sha256-AaBWSysNpZ7NV10RGD4TehZqE0k8Sn+TlhlGw1PiRdI="; 40 }) 41 ]; 42 43 outputs = [ 44 "out" 45 "dev" 46 ]; 47 48 nativeBuildInputs = [ 49 cmake 50 ninja 51 swift 52 ]; 53 buildInputs = [ 54 icu 55 libxml2 56 curl 57 ]; 58 propagatedBuildInputs = [ Dispatch ]; 59 60 preConfigure = '' 61 # Fails to build with -D_FORTIFY_SOURCE. 62 NIX_HARDENING_ENABLE=''${NIX_HARDENING_ENABLE/fortify/} 63 ''; 64 65 postInstall = '' 66 # Split up the output. 67 mkdir $dev 68 mv $out/lib/swift/${swift.swiftOs} $out/swiftlibs 69 mv $out/lib/swift $dev/include 70 mkdir $out/lib/swift 71 mv $out/swiftlibs $out/lib/swift/${swift.swiftOs} 72 73 # Provide a CMake module. This is primarily used to glue together parts of 74 # the Swift toolchain. Modifying the CMake config to do this for us is 75 # otherwise more trouble. 76 mkdir -p $dev/lib/cmake/Foundation 77 export dylibExt="${stdenv.hostPlatform.extensions.sharedLibrary}" 78 export swiftOs="${swift.swiftOs}" 79 substituteAll ${./glue.cmake} $dev/lib/cmake/Foundation/FoundationConfig.cmake 80 ''; 81 82 meta = { 83 description = "Core utilities, internationalization, and OS independence for Swift"; 84 mainProgram = "plutil"; 85 homepage = "https://github.com/apple/swift-corelibs-foundation"; 86 platforms = lib.platforms.linux; 87 license = lib.licenses.asl20; 88 teams = [ lib.teams.swift ]; 89 }; 90}