nixpkgs/pkgs/development/compilers/swift/default.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

108 lines
3.2 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
lib,
pkgs,
newScope,
darwin,
llvmPackages,
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.
# 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;
# 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.
#
# 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
# 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 {
inherit (darwin) DarwinTools sigtool;
};
swiftNoSwiftDriver = callPackage ./wrapper {
swift = swift-unwrapped;
useSwiftDriver = false;
};
Dispatch =
if stdenv.hostPlatform.isDarwin then
null # part of apple-sdk
else
callPackage ./libdispatch { swift = swiftNoSwiftDriver; };
Foundation =
if stdenv.hostPlatform.isDarwin then
null # part of apple-sdk
else
callPackage ./foundation { swift = swiftNoSwiftDriver; };
# 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;
swift = swiftNoSwiftDriver;
};
swiftpm = callPackage ./swiftpm {
inherit (darwin) DarwinTools;
inherit (apple_sdk.frameworks) CryptoKit LocalAuthentication;
swift = swiftNoSwiftDriver;
};
swift-driver = callPackage ./swift-driver {
swift = swiftNoSwiftDriver;
};
swift = callPackage ./wrapper {
swift = swift-unwrapped;
};
sourcekit-lsp = callPackage ./sourcekit-lsp {
inherit (apple_sdk.frameworks) CryptoKit LocalAuthentication;
};
swift-docc = callPackage ./swift-docc {
inherit (apple_sdk.frameworks) CryptoKit LocalAuthentication;
};
swift-format = callPackage ./swift-format { };
swiftpm2nix = callPackage ./swiftpm2nix { };
};
in
self