From 0f9067f865a22aa6c1fe94eed7f218287b3e9425 Mon Sep 17 00:00:00 2001 From: Emily Date: Sat, 5 Oct 2024 18:44:35 +0100 Subject: [PATCH] darwin: set the minimum version to macOS 11.3 --- doc/stdenv/platform-notes.chapter.md | 35 +++++------ lib/systems/default.nix | 2 +- .../darwin/apple-sdk-11.0/default.nix | 59 ++++--------------- pkgs/stdenv/darwin/override-sdk.nix | 36 ++++------- pkgs/top-level/darwin-packages.nix | 7 +-- 5 files changed, 41 insertions(+), 98 deletions(-) diff --git a/doc/stdenv/platform-notes.chapter.md b/doc/stdenv/platform-notes.chapter.md index 7e06a9bab30f..3f7296d32653 100644 --- a/doc/stdenv/platform-notes.chapter.md +++ b/doc/stdenv/platform-notes.chapter.md @@ -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. Check your package’s 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)
11.3 (aarch64-darwin) | `apple-sdk` | -| 8.0–8.3.3 | 10.12.2 | `apple-sdk_10_12` | -| 9.0–9.4.1 | 10.13.2 | `apple-sdk_10_13` | -| 10.0–10.3 | 10.14.6 | `apple-sdk_10_14` | -| 11.0–11.7 | 10.15.6 | `apple-sdk_10_15` | -| 12.0–12.5.1 | 11.3 | `apple-sdk_11` | -| 13.0–13.4.1 | 12.3 | `apple-sdk_12` | -| 14.0–14.3.1 | 13.3 | `apple-sdk_13` | -| 15.0–15.4 | 14.4 | `apple-sdk_14` | -| 16.0 | 15.0 | `apple-sdk_15` | +| Xcode version | SDK version | Nixpkgs attribute | +|--------------------|--------------------|------------------------------| +| 12.0–12.5.1 | 11.3 | `apple-sdk_11` / `apple-sdk` | +| 13.0–13.4.1 | 12.3 | `apple-sdk_12` | +| 14.0–14.3.1 | 13.3 | `apple-sdk_13` | +| 15.0–15.4 | 14.4 | `apple-sdk_14` | +| 16.0 | 15.0 | `apple-sdk_15` | #### 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 derivation’s 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. diff --git a/lib/systems/default.nix b/lib/systems/default.nix index a6ceef2cc3a1..52383db0a36d 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -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" diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/default.nix b/pkgs/os-specific/darwin/apple-sdk-11.0/default.nix index c3547aae44ed..8f283c6bec54 100644 --- a/pkgs/os-specific/darwin/apple-sdk-11.0/default.nix +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/default.nix @@ -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 - ; - }; - - stdenv = overrideSDK stdenv "11.0"; - - xcodebuild = pkgs.xcodebuild; + inherit (pkgs) + callPackage + stdenv + llvmPackages_12 + llvmPackages_13 + llvmPackages_14 + llvmPackages_15 + llvmPackages_16 + rustPlatform + xcodebuild + ; version = "11.0"; } diff --git a/pkgs/stdenv/darwin/override-sdk.nix b/pkgs/stdenv/darwin/override-sdk.nix index 243b8e2633d7..482c11ce0cb2 100644 --- a/pkgs/stdenv/darwin/override-sdk.nix +++ b/pkgs/stdenv/darwin/override-sdk.nix @@ -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 '' - `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`. - ''); + 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`. +''; 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 + ); }); }) diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix index ab8d9c387b40..669e268b9001 100644 --- a/pkgs/top-level/darwin-packages.nix +++ b/pkgs/top-level/darwin-packages.nix @@ -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;