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,31 +87,24 @@ 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. 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. 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 | | Xcode version | SDK version | Nixpkgs attribute |
|--------------------|---------------------------------------------------|-------------------| |--------------------|--------------------|------------------------------|
| Varies by platform | 10.12.2 (x86_64-darwin)<br/>11.3 (aarch64-darwin) | `apple-sdk` | | 12.012.5.1 | 11.3 | `apple-sdk_11` / `apple-sdk` |
| 8.08.3.3 | 10.12.2 | `apple-sdk_10_12` | | 13.013.4.1 | 12.3 | `apple-sdk_12` |
| 9.09.4.1 | 10.13.2 | `apple-sdk_10_13` | | 14.014.3.1 | 13.3 | `apple-sdk_13` |
| 10.010.3 | 10.14.6 | `apple-sdk_10_14` | | 15.015.4 | 14.4 | `apple-sdk_14` |
| 11.011.7 | 10.15.6 | `apple-sdk_10_15` | | 16.0 | 15.0 | `apple-sdk_15` |
| 12.012.5.1 | 11.3 | `apple-sdk_11` |
| 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` |
| 16.0 | 15.0 | `apple-sdk_15` |
#### Darwin Default SDK versions {#sec-darwin-troubleshooting-darwin-defaults} #### 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. 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. On macOS, the `darwinMinVersion` and `darwinSdkVersion` are always the same, and are currently set to 11.3.
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.
#### `xcrun` cannot find a binary {#sec-darwin-troubleshooting-xcrun} #### `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. 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. 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. - `pkgs.darwin.apple_sdk_11_0.callPackage` - this pattern was used to provide frameworks from the macOS 11 SDK.
It now adds the `apple-sdk_11` package to your derivations build inputs. 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. - `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. If `darwinMinVersion` is specified, it will add `darwinMinVersionHook` with the specified minimum version.
No other SDK versions are supported. No other SDK versions are supported.

View File

@ -251,7 +251,7 @@ let
else null; else null;
# The canonical name for this attribute is darwinSdkVersion, but some # The canonical name for this attribute is darwinSdkVersion, but some
# platforms define the old name "sdkVer". # 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; darwinMinVersion = final.darwinSdkVersion;
darwinMinVersionVariable = darwinMinVersionVariable =
if final.isMacOS then "MACOSX_DEPLOYMENT_TARGET" if final.isMacOS then "MACOSX_DEPLOYMENT_TARGET"

View File

@ -12,30 +12,8 @@
let let
mkStub = callPackage ../apple-sdk/mk-stub.nix { } "11.0"; 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 in
stdenvs lib.genAttrs [
// lib.genAttrs [
"CLTools_Executables" "CLTools_Executables"
"IOKit" "IOKit"
"Libsystem" "Libsystem"
@ -276,30 +254,17 @@ stdenvs
"simd" "simd"
] mkStub; ] mkStub;
callPackage = newScope ( inherit (pkgs)
lib.optionalAttrs stdenv.hostPlatform.isDarwin ( callPackage
stdenvs // { inherit (pkgs.darwin.apple_sdk_11_0) rustPlatform; } stdenv
) llvmPackages_12
); llvmPackages_13
llvmPackages_14
rustPlatform = llvmPackages_15
pkgs.makeRustPlatform { llvmPackages_16
inherit (pkgs.darwin.apple_sdk_11_0) stdenv; rustPlatform
inherit (pkgs) rustc cargo; xcodebuild
} ;
// {
inherit
(pkgs.callPackage ../../../build-support/rust/hooks {
inherit (pkgs.darwin.apple_sdk_11_0) stdenv;
inherit (pkgs) cargo rustc;
})
bindgenHook
;
};
stdenv = overrideSDK stdenv "11.0";
xcodebuild = pkgs.xcodebuild;
version = "11.0"; version = "11.0";
} }

View File

@ -9,33 +9,23 @@
stdenv: sdkVersion: stdenv: sdkVersion:
let let
newVersion = { darwinSdkVersion =
inherit (stdenv.hostPlatform) darwinMinVersion darwinSdkVersion; if lib.isAttrs sdkVersion then sdkVersion.darwinSdkVersion or "11.0" else sdkVersion;
} // (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 ''
`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 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`.
'';
stdenv.override (old: { stdenv.override (old: {
mkDerivationFromStdenv = extendMkDerivationArgs old (args: { mkDerivationFromStdenv = extendMkDerivationArgs old (args: {
buildInputs = buildInputs =
args.buildInputs or [ ] args.buildInputs or [ ]
++ lib.optional (stdenv.hostPlatform.darwinMinVersion != darwinMinVersion) minVersionHook ++ lib.optional (darwinSdkVersion == "12.3") pkgsHostTarget.apple-sdk_12
++ lib.optional (stdenv.hostPlatform.darwinSdkVersion != darwinSdkVersion) resolvedSdk; ++ lib.optional (sdkVersion ? darwinMinVersion) (
pkgsHostTarget.darwinMinVersionHook sdkVersion.darwinMinVersion
);
}); });
}) })

View File

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