Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 pkgs, 4 newScope, 5 darwin, 6 llvmPackages, 7 llvmPackages_15, 8 overrideCC, 9 overrideLibcxx, 10}: 11 12let 13 swiftLlvmPackages = llvmPackages_15; 14 15 self = rec { 16 17 callPackage = newScope self; 18 19 # Swift builds its own Clang for internal use. We wrap that clang with a 20 # cc-wrapper derived from the clang configured below. Because cc-wrapper 21 # applies a specific resource-root, the two versions are best matched, or 22 # we'll often run into compilation errors. 23 # 24 # The following selects the correct Clang version, matching the version 25 # used in Swift. 26 inherit (swiftLlvmPackages) clang; 27 28 # Overrides that create a useful environment for swift packages, allowing 29 # packaging with `swiftPackages.callPackage`. 30 inherit (clang) bintools; 31 stdenv = 32 let 33 stdenv' = overrideCC pkgs.stdenv clang; 34 in 35 # Ensure that Swift’s internal clang uses the same libc++ and libc++abi as the 36 # default clang’s stdenv. Using the default libc++ avoids issues (such as crashes) 37 # that can happen when a Swift application dynamically links different versions 38 # of libc++ and libc++abi than libraries it links are using. 39 if stdenv'.cc.libcxx != null then overrideLibcxx stdenv' else stdenv'; 40 41 swift-unwrapped = callPackage ./compiler { 42 inherit (darwin) DarwinTools sigtool; 43 }; 44 45 swiftNoSwiftDriver = callPackage ./wrapper { 46 swift = swift-unwrapped; 47 useSwiftDriver = false; 48 }; 49 50 Dispatch = 51 if stdenv.hostPlatform.isDarwin then 52 null # part of apple-sdk 53 else 54 callPackage ./libdispatch { swift = swiftNoSwiftDriver; }; 55 56 Foundation = 57 if stdenv.hostPlatform.isDarwin then 58 null # part of apple-sdk 59 else 60 callPackage ./foundation { swift = swiftNoSwiftDriver; }; 61 62 # TODO: Apple distributes a binary XCTest with Xcode, but it is not part of 63 # CLTools (or SUS), so would have to figure out how to fetch it. The binary 64 # version has several extra features, like a test runner and ObjC support. 65 XCTest = callPackage ./xctest { 66 inherit (darwin) DarwinTools; 67 swift = swiftNoSwiftDriver; 68 }; 69 70 swiftpm = callPackage ./swiftpm { 71 inherit (darwin) DarwinTools; 72 swift = swiftNoSwiftDriver; 73 }; 74 75 swift-driver = callPackage ./swift-driver { 76 swift = swiftNoSwiftDriver; 77 }; 78 79 swift = callPackage ./wrapper { 80 swift = swift-unwrapped; 81 }; 82 83 sourcekit-lsp = callPackage ./sourcekit-lsp { }; 84 85 swift-docc = callPackage ./swift-docc { }; 86 87 swift-format = callPackage ./swift-format { }; 88 89 swiftpm2nix = callPackage ./swiftpm2nix { }; 90 91 }; 92 93in 94self