1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-21 08:59:20 +03:00
nixpkgs/pkgs/development/compilers/swift/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

102 lines
3.2 KiB
Nix
Raw Normal View History

{ lib
, pkgs
, newScope
, darwin
, llvmPackages
2023-04-01 21:43:12 +02:00
, llvmPackages_15
, overrideCC
, overrideLibcxx
}:
let
swiftLlvmPackages = llvmPackages_15;
self = rec {
callPackage = newScope self;
# Current versions of Swift on Darwin require macOS SDK 10.15 at least.
2024-09-25 21:47:47 -04:00
# The Swift compiler propagates the 13.3 SDK and a 10.15 deployment target.
# Packages that need a newer version can add it to their build inputs
# to use it (as normal).
# This SDK is included for compatibility with existing packages.
apple_sdk = pkgs.darwin.apple_sdk_11_0;
2023-04-01 21:43:12 +02:00
# Swift builds its own Clang for internal use. We wrap that clang with a
# cc-wrapper derived from the clang configured below. Because cc-wrapper
# applies a specific resource-root, the two versions are best matched, or
# we'll often run into compilation errors.
#
2023-04-01 21:43:12 +02:00
# The following selects the correct Clang version, matching the version
# used in Swift.
inherit (swiftLlvmPackages) clang;
# Overrides that create a useful environment for swift packages, allowing
2024-09-25 21:47:47 -04:00
# packaging with `swiftPackages.callPackage`.
inherit (clang) bintools;
stdenv =
let
stdenv' = overrideCC pkgs.stdenv clang;
in
# Ensure that Swifts internal clang uses the same libc++ and libc++abi as the
# default clangs stdenv. Using the default libc++ avoids issues (such as crashes)
# that can happen when a Swift application dynamically links different versions
# of libc++ and libc++abi than libraries it links are using.
if stdenv'.cc.libcxx != null then overrideLibcxx stdenv' else stdenv';
swift-unwrapped = callPackage ./compiler {
2024-07-17 22:16:28 -04:00
inherit (darwin) DarwinTools sigtool;
};
2022-08-26 08:09:17 +02:00
swiftNoSwiftDriver = callPackage ./wrapper {
swift = swift-unwrapped;
2022-08-26 08:09:17 +02:00
useSwiftDriver = false;
};
2021-08-01 11:25:01 -04:00
2022-07-25 20:36:50 +02:00
Dispatch = if stdenv.hostPlatform.isDarwin
2024-09-25 21:47:47 -04:00
then null # part of apple-sdk
2022-08-26 08:09:17 +02:00
else callPackage ./libdispatch { swift = swiftNoSwiftDriver; };
2022-07-25 20:36:50 +02:00
2022-07-25 21:42:22 +02:00
Foundation = if stdenv.hostPlatform.isDarwin
then null # part of apple-sdk
2022-08-26 08:09:17 +02:00
else callPackage ./foundation { swift = swiftNoSwiftDriver; };
2022-07-25 21:42:22 +02:00
2022-07-25 21:45:15 +02:00
# TODO: Apple distributes a binary XCTest with Xcode, but it is not part of
# CLTools (or SUS), so would have to figure out how to fetch it. The binary
# version has several extra features, like a test runner and ObjC support.
XCTest = callPackage ./xctest {
inherit (darwin) DarwinTools;
2022-08-26 08:09:17 +02:00
swift = swiftNoSwiftDriver;
2022-07-25 21:45:15 +02:00
};
2022-07-25 21:57:00 +02:00
swiftpm = callPackage ./swiftpm {
2024-07-17 22:16:28 -04:00
inherit (darwin) DarwinTools;
2022-07-25 21:57:00 +02:00
inherit (apple_sdk.frameworks) CryptoKit LocalAuthentication;
2022-08-26 08:09:17 +02:00
swift = swiftNoSwiftDriver;
};
swift-driver = callPackage ./swift-driver {
swift = swiftNoSwiftDriver;
};
swift = callPackage ./wrapper {
swift = swift-unwrapped;
2022-07-25 21:57:00 +02:00
};
2022-07-30 17:33:18 +02:00
sourcekit-lsp = callPackage ./sourcekit-lsp {
inherit (apple_sdk.frameworks) CryptoKit LocalAuthentication;
};
2022-08-26 08:09:01 +02:00
swift-docc = callPackage ./swift-docc {
inherit (apple_sdk.frameworks) CryptoKit LocalAuthentication;
};
2023-05-06 13:26:53 +02:00
swift-format = callPackage ./swift-format { };
swiftpm2nix = callPackage ./swiftpm2nix { };
};
in self