From 3086152b77c2f87ac50df60ca10290bcd8cce60b Mon Sep 17 00:00:00 2001 From: toonn Date: Fri, 8 Jul 2022 12:28:51 +0200 Subject: [PATCH] Merge pull request #176661 from reckenrode/apple-sdk-11-x86_64 apple_sdk_11_0: make available for use on x86_64-darwin --- doc/stdenv/platform-notes.chapter.md | 5 +++ .../darwin/apple-sdk-11.0/apple_sdk.nix | 4 +-- .../darwin/apple-sdk-11.0/default.nix | 33 ++++++++++++++++++- pkgs/top-level/darwin-packages.nix | 2 +- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/doc/stdenv/platform-notes.chapter.md b/doc/stdenv/platform-notes.chapter.md index 03e61e333f8b2..b47f5af349b8d 100644 --- a/doc/stdenv/platform-notes.chapter.md +++ b/doc/stdenv/platform-notes.chapter.md @@ -60,3 +60,8 @@ Some common issues when packaging software for Darwin: ``` The package `xcbuild` can be used to build projects that really depend on Xcode. However, this replacement is not 100% compatible with Xcode and can occasionally cause issues. + +- x86_64-darwin uses the 10.12 SDK by default, but some software is not compatible with that version of the SDK. In that case, + the 11.0 SDK used by aarch64-darwin is available for use on x86_64-darwin. To use it, reference `apple_sdk_11_0` instead of + `apple_sdk` in your derivation and use `pkgs.darwin.apple_sdk_11_0.callPackage` instead of `pkgs.callPackage`. On Linux, this will + have the same effect as `pkgs.callPackage`, so you can use `pkgs.darwin.apple_sdk_11_0.callPackage` regardless of platform. diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix b/pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix index 228a084d250fb..05340642f8d04 100644 --- a/pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix @@ -168,8 +168,8 @@ in rec { bareFrameworks = ( lib.mapAttrs framework (import ./frameworks.nix { inherit frameworks libs; - inherit (pkgs.darwin) libobjc Libsystem; - inherit (pkgs.darwin.apple_sdk) libnetwork; + inherit (pkgs.darwin.apple_sdk_11_0) libnetwork Libsystem; + libobjc = pkgs.darwin.apple_sdk_11_0.objc4; }) ) // ( lib.mapAttrs privateFramework (import ./private-frameworks.nix { 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 44b119e1a23e9..b29a36177a825 100644 --- a/pkgs/os-specific/darwin/apple-sdk-11.0/default.nix +++ b/pkgs/os-specific/darwin/apple-sdk-11.0/default.nix @@ -1,4 +1,5 @@ -{ stdenvNoCC, fetchurl, newScope, pkgs +{ stdenvNoCC, fetchurl, newScope, lib, pkgs +, stdenv, overrideCC , xar, cpio, python3, pbzx }: let @@ -54,5 +55,35 @@ let # questionable aliases configd = pkgs.darwin.apple_sdk.frameworks.SystemConfiguration; IOKit = pkgs.darwin.apple_sdk.frameworks.IOKit; + + callPackage = newScope (lib.optionalAttrs stdenv.isDarwin rec { + inherit (pkgs.darwin.apple_sdk_11_0) stdenv; + darwin = pkgs.darwin.overrideScope (_: prev: { + inherit (prev.darwin.apple_sdk_11_0) Libsystem LibsystemCross libcharset libunwind objc4 configd IOKit Security; + apple_sdk = prev.darwin.apple_sdk_11_0; + CF = prev.darwin.apple_sdk_11_0.CoreFoundation; + }); + xcodebuild = pkgs.xcbuild.override { + inherit (pkgs.darwin.apple_sdk_11_0.frameworks) CoreServices CoreGraphics ImageIO; + inherit stdenv; + }; + xcbuild = xcodebuild; + }); + + stdenv = + let + clang = stdenv.cc.override { + bintools = stdenv.cc.bintools.override { libc = packages.Libsystem; }; + libc = packages.Libsystem; + }; + in + if stdenv.isAarch64 then stdenv + else + (overrideCC stdenv clang).override { + targetPlatform = stdenv.targetPlatform // { + darwinMinVersion = "10.12"; + darwinSdkVersion = "11.0"; + }; + }; }; in packages diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix index ff23949ae4faf..2537a8e73318f 100644 --- a/pkgs/top-level/darwin-packages.nix +++ b/pkgs/top-level/darwin-packages.nix @@ -70,7 +70,7 @@ in impure-cmds // appleSourcePackages // chooseLibs // { - inherit apple_sdk; + inherit apple_sdk apple_sdk_10_12 apple_sdk_11_0; stdenvNoCF = stdenv.override { extraBuildInputs = [];