Skip to content

Commit

Permalink
Merge pull request NixOS#176661 from reckenrode/apple-sdk-11-x86_64
Browse files Browse the repository at this point in the history
apple_sdk_11_0: make available for use on x86_64-darwin
  • Loading branch information
toonn authored and jsoo1 committed Jul 14, 2023
1 parent 1c3a7b7 commit bb819f0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
5 changes: 5 additions & 0 deletions doc/stdenv/platform-notes.chapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
33 changes: 32 additions & 1 deletion pkgs/os-specific/darwin/apple-sdk-11.0/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ stdenvNoCC, fetchurl, newScope, pkgs
{ stdenvNoCC, fetchurl, newScope, lib, pkgs
, stdenv, overrideCC
, xar, cpio, python3, pbzx }:

let
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion pkgs/top-level/darwin-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down

0 comments on commit bb819f0

Please sign in to comment.