fork
Configure Feed
Select the types of activity you want to include in your feed.
nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
fork
Configure Feed
Select the types of activity you want to include in your feed.
1{ lib
2, pkgs
3, newScope
4, darwin
5, llvmPackages
6, llvmPackages_15
7, overrideCC
8}:
9
10let
11 swiftLlvmPackages = llvmPackages_15;
12
13 self = rec {
14
15 callPackage = newScope self;
16
17 # Current versions of Swift on Darwin require macOS SDK 10.15 at least.
18 # Re-export this so we can rely on the minimum Swift SDK elsewhere.
19 apple_sdk = pkgs.darwin.apple_sdk_11_0;
20
21 # Swift builds its own Clang for internal use. We wrap that clang with a
22 # cc-wrapper derived from the clang configured below. Because cc-wrapper
23 # applies a specific resource-root, the two versions are best matched, or
24 # we'll often run into compilation errors.
25 #
26 # The following selects the correct Clang version, matching the version
27 # used in Swift, and applies the same libc overrides as `apple_sdk.stdenv`.
28 clang = if pkgs.stdenv.isDarwin
29 then
30 swiftLlvmPackages.clang.override rec {
31 libc = apple_sdk.Libsystem;
32 bintools = pkgs.bintools.override { inherit libc; };
33 # Ensure that Swift’s internal clang uses the same libc++ and libc++abi as the
34 # default Darwin stdenv. Using the default libc++ avoids issues (such as crashes)
35 # that can happen when a Swift application dynamically links different versions
36 # of libc++ and libc++abi than libraries it links are using.
37 inherit (llvmPackages) libcxx;
38 extraPackages = [
39 llvmPackages.libcxxabi
40 # Use the compiler-rt associated with clang, but use the libc++abi from the stdenv
41 # to avoid linking against two different versions (for the same reasons as above).
42 (swiftLlvmPackages.compiler-rt.override {
43 inherit (llvmPackages) libcxxabi;
44 })
45 ];
46 }
47 else
48 swiftLlvmPackages.clang;
49
50 # Overrides that create a useful environment for swift packages, allowing
51 # packaging with `swiftPackages.callPackage`. These are similar to
52 # `apple_sdk_11_0.callPackage`, with our clang on top.
53 inherit (clang) bintools;
54 stdenv = overrideCC pkgs.stdenv clang;
55 darwin = pkgs.darwin.overrideScope (_: prev: {
56 inherit apple_sdk;
57 inherit (apple_sdk) Libsystem LibsystemCross libcharset libunwind objc4 configd IOKit Security;
58 CF = apple_sdk.CoreFoundation;
59 });
60 xcodebuild = pkgs.xcbuild.override {
61 inherit (apple_sdk.frameworks) CoreServices CoreGraphics ImageIO;
62 inherit stdenv;
63 sdkVer = "10.15";
64 };
65 xcbuild = xcodebuild;
66
67 swift-unwrapped = callPackage ./compiler {
68 inherit (darwin) DarwinTools cctools sigtool;
69 inherit (apple_sdk) MacOSX-SDK CLTools_Executables;
70 inherit (apple_sdk.frameworks) CoreServices Foundation Combine;
71 };
72
73 swiftNoSwiftDriver = callPackage ./wrapper {
74 swift = swift-unwrapped;
75 useSwiftDriver = false;
76 };
77
78 Dispatch = if stdenv.isDarwin
79 then null # part of libsystem
80 else callPackage ./libdispatch { swift = swiftNoSwiftDriver; };
81
82 Foundation = if stdenv.isDarwin
83 then apple_sdk.frameworks.Foundation
84 else callPackage ./foundation { swift = swiftNoSwiftDriver; };
85
86 # TODO: Apple distributes a binary XCTest with Xcode, but it is not part of
87 # CLTools (or SUS), so would have to figure out how to fetch it. The binary
88 # version has several extra features, like a test runner and ObjC support.
89 XCTest = callPackage ./xctest {
90 inherit (darwin) DarwinTools;
91 swift = swiftNoSwiftDriver;
92 };
93
94 swiftpm = callPackage ./swiftpm {
95 inherit (darwin) DarwinTools cctools;
96 inherit (apple_sdk.frameworks) CryptoKit LocalAuthentication;
97 swift = swiftNoSwiftDriver;
98 };
99
100 swift-driver = callPackage ./swift-driver {
101 swift = swiftNoSwiftDriver;
102 };
103
104 swift = callPackage ./wrapper {
105 swift = swift-unwrapped;
106 };
107
108 sourcekit-lsp = callPackage ./sourcekit-lsp {
109 inherit (apple_sdk.frameworks) CryptoKit LocalAuthentication;
110 };
111
112 swift-docc = callPackage ./swift-docc {
113 inherit (apple_sdk.frameworks) CryptoKit LocalAuthentication;
114 };
115
116 swift-format = callPackage ./swift-format { };
117
118 };
119
120in self