darwin: set the minimum version to macOS 11.3

This commit is contained in:
Emily 2024-10-05 18:44:35 +01:00
parent 80f7c3ddbf
commit 0f9067f865
5 changed files with 41 additions and 98 deletions

View File

@ -87,16 +87,11 @@ When that happens, the one with the highest version is always used.
The following is a list of Xcode versions, the SDK version in Nixpkgs, and the attribute to use to add it.
Check your packages documentation (platform support or installation instructions) to find which Xcode or SDK version to use.
Generally, only the last SDK release for a major version is packaged (each _x_ in 10._x_ until 10.15 is considered a major version).
Generally, only the last SDK release for a major version is packaged.
| Xcode version | SDK version | Nixpkgs attribute |
|--------------------|---------------------------------------------------|-------------------|
| Varies by platform | 10.12.2 (x86_64-darwin)<br/>11.3 (aarch64-darwin) | `apple-sdk` |
| 8.08.3.3 | 10.12.2 | `apple-sdk_10_12` |
| 9.09.4.1 | 10.13.2 | `apple-sdk_10_13` |
| 10.010.3 | 10.14.6 | `apple-sdk_10_14` |
| 11.011.7 | 10.15.6 | `apple-sdk_10_15` |
| 12.012.5.1 | 11.3 | `apple-sdk_11` |
|--------------------|--------------------|------------------------------|
| 12.012.5.1 | 11.3 | `apple-sdk_11` / `apple-sdk` |
| 13.013.4.1 | 12.3 | `apple-sdk_12` |
| 14.014.3.1 | 13.3 | `apple-sdk_13` |
| 15.015.4 | 14.4 | `apple-sdk_14` |
@ -105,13 +100,11 @@ Generally, only the last SDK release for a major version is packaged (each _x_ i
#### Darwin Default SDK versions {#sec-darwin-troubleshooting-darwin-defaults}
The current default versions of the deployment target (minimum version) and SDK are indicated by Darwin-specific attributes on the platform. Because of the ways that minimum version and SDK can be changed that are not visible to Nix, they should be treated as lower bounds.
The current default version of the SDK and deployment target (minimum supported version) are indicated by the Darwin-specific platform attributes `darwinSdkVersion` and `darwinMinVersion`.
Because of the ways that minimum version and SDK can be changed that are not visible to Nix, they should be treated as lower bounds.
If you need to parameterize over a specific version, create a function that takes the version as a parameter instead of relying on these attributes.
- `darwinMinVersion` defaults to 10.12 on x86_64-darwin and 11.0 on aarch64-darwin.
It sets the default deployment target.
- `darwinSdkVersion` defaults to 10.12 on x86-64-darwin and 11.0 on aarch64-darwin.
Only the major version determines the SDK version, resulting in the 10.12.2 and 11.3 SDKs being used on these platforms respectively.
On macOS, the `darwinMinVersion` and `darwinSdkVersion` are always the same, and are currently set to 11.3.
#### `xcrun` cannot find a binary {#sec-darwin-troubleshooting-xcrun}
@ -264,10 +257,10 @@ The legacy SDK provided two ways of overriding the default SDK.
These are both being phased out along with the legacy SDKs.
They have been updated to set up the new SDK for you, but you should replace them with doing that directly.
- `pkgs.darwin.apple_sdk_11_0.callPackage` - this pattern was used to provide frameworks from the 11.0 SDK.
It now adds the `apple-sdk_11` package to your derivations build inputs.
- `pkgs.darwin.apple_sdk_11_0.callPackage` - this pattern was used to provide frameworks from the macOS 11 SDK.
It is now the same as `callPackage`.
- `overrideSDK` - this stdenv adapter would try to replace the frameworks used by your derivation and its transitive dependencies.
It now adds the `apple-sdk_11` package for `11.0` or the `apple-sdk_12` package for `12.3`.
It now adds the `apple-sdk_12` package for `12.3` and does nothing for `11.0`.
If `darwinMinVersion` is specified, it will add `darwinMinVersionHook` with the specified minimum version.
No other SDK versions are supported.

View File

@ -251,7 +251,7 @@ let
else null;
# The canonical name for this attribute is darwinSdkVersion, but some
# platforms define the old name "sdkVer".
darwinSdkVersion = final.sdkVer or (if final.isAarch64 then "11.0" else "10.12");
darwinSdkVersion = final.sdkVer or "11.3";
darwinMinVersion = final.darwinSdkVersion;
darwinMinVersionVariable =
if final.isMacOS then "MACOSX_DEPLOYMENT_TARGET"

View File

@ -12,30 +12,8 @@
let
mkStub = callPackage ../apple-sdk/mk-stub.nix { } "11.0";
stdenvs =
{
stdenv = overrideSDK stdenv "11.0";
}
// builtins.listToAttrs (
map
(v: {
name = "llvmPackages_${v}";
value = pkgs."llvmPackages_${v}" // {
stdenv = overrideSDK pkgs."llvmPackages_${v}".stdenv "11.0";
};
})
[
"12"
"13"
"14"
"15"
"16"
]
);
in
stdenvs
// lib.genAttrs [
lib.genAttrs [
"CLTools_Executables"
"IOKit"
"Libsystem"
@ -276,30 +254,17 @@ stdenvs
"simd"
] mkStub;
callPackage = newScope (
lib.optionalAttrs stdenv.hostPlatform.isDarwin (
stdenvs // { inherit (pkgs.darwin.apple_sdk_11_0) rustPlatform; }
)
);
rustPlatform =
pkgs.makeRustPlatform {
inherit (pkgs.darwin.apple_sdk_11_0) stdenv;
inherit (pkgs) rustc cargo;
}
// {
inherit
(pkgs.callPackage ../../../build-support/rust/hooks {
inherit (pkgs.darwin.apple_sdk_11_0) stdenv;
inherit (pkgs) cargo rustc;
})
bindgenHook
inherit (pkgs)
callPackage
stdenv
llvmPackages_12
llvmPackages_13
llvmPackages_14
llvmPackages_15
llvmPackages_16
rustPlatform
xcodebuild
;
};
stdenv = overrideSDK stdenv "11.0";
xcodebuild = pkgs.xcodebuild;
version = "11.0";
}

View File

@ -9,33 +9,23 @@
stdenv: sdkVersion:
let
newVersion = {
inherit (stdenv.hostPlatform) darwinMinVersion darwinSdkVersion;
} // (if lib.isAttrs sdkVersion then sdkVersion else { darwinSdkVersion = sdkVersion; });
inherit (newVersion) darwinMinVersion darwinSdkVersion;
sdkMapping = {
"11.0" = pkgsHostTarget.apple-sdk_11;
"12.3" = pkgsHostTarget.apple-sdk_12;
};
minVersionHook = pkgsHostTarget.darwinMinVersionHook darwinMinVersion;
resolvedSdk =
sdkMapping.${darwinSdkVersion} or (lib.throw ''
darwinSdkVersion =
if lib.isAttrs sdkVersion then sdkVersion.darwinSdkVersion or "11.0" else sdkVersion;
in
assert lib.assertMsg (darwinSdkVersion == "11.0" || darwinSdkVersion == "12.3") ''
`overrideSDK` and `darwin.apple_sdk_11_0.callPackage` are deprecated.
Only the 11.0 and 12.3 SDKs are supported using them. Please use
the versioned `apple-sdk` variants to use other SDK versions.
See the stdenv documentation for how to use `apple-sdk`.
'');
in
'';
stdenv.override (old: {
mkDerivationFromStdenv = extendMkDerivationArgs old (args: {
buildInputs =
args.buildInputs or [ ]
++ lib.optional (stdenv.hostPlatform.darwinMinVersion != darwinMinVersion) minVersionHook
++ lib.optional (stdenv.hostPlatform.darwinSdkVersion != darwinSdkVersion) resolvedSdk;
++ lib.optional (darwinSdkVersion == "12.3") pkgsHostTarget.apple-sdk_12
++ lib.optional (sdkVersion ? darwinMinVersion) (
pkgsHostTarget.darwinMinVersionHook sdkVersion.darwinMinVersion
);
});
})

View File

@ -66,12 +66,7 @@ makeScopeWithSplicing' {
# macOS 12.3 SDK
apple_sdk_12_3 = pkgs.callPackage ../os-specific/darwin/apple-sdk-12.3 { };
# Pick an SDK
apple_sdk = {
"10.12" = apple_sdk_10_12;
"11.0" = apple_sdk_11_0;
}.${stdenv.hostPlatform.darwinSdkVersion}
or (throw "Unsupported sdk: ${stdenv.hostPlatform.darwinSdkVersion}");
apple_sdk = apple_sdk_11_0;
stubs = {
inherit apple_sdk apple_sdk_10_12 apple_sdk_11_0 apple_sdk_12_3;