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
33 outputs = [
34 "out"
35 "dev"
36 ];
37
38 nativeBuildInputs = [
39 cmake
40 ninja
41 swift
42 ];
43 buildInputs = [
44 icu
45 libxml2
46 curl
47 ];
48 propagatedBuildInputs = [ Dispatch ];
49
50 preConfigure = ''
51 # Fails to build with -D_FORTIFY_SOURCE.
52 NIX_HARDENING_ENABLE=''${NIX_HARDENING_ENABLE/fortify/}
53 '';
54
55 postInstall = ''
56 # Split up the output.
57 mkdir $dev
58 mv $out/lib/swift/${swift.swiftOs} $out/swiftlibs
59 mv $out/lib/swift $dev/include
60 mkdir $out/lib/swift
61 mv $out/swiftlibs $out/lib/swift/${swift.swiftOs}
62
63 # Provide a CMake module. This is primarily used to glue together parts of
64 # the Swift toolchain. Modifying the CMake config to do this for us is
65 # otherwise more trouble.
66 mkdir -p $dev/lib/cmake/Foundation
67 export dylibExt="${stdenv.hostPlatform.extensions.sharedLibrary}"
68 export swiftOs="${swift.swiftOs}"
69 substituteAll ${./glue.cmake} $dev/lib/cmake/Foundation/FoundationConfig.cmake
70 '';
71
72 meta = {
73 description = "Core utilities, internationalization, and OS independence for Swift";
74 mainProgram = "plutil";
75 homepage = "https://github.com/apple/swift-corelibs-foundation";
76 platforms = lib.platforms.linux;
77 license = lib.licenses.asl20;
78 teams = [ lib.teams.swift ];
79 };
80}