2024-05-02 00:46:19 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildPackages,
|
|
|
|
pkgs,
|
|
|
|
targetPackages,
|
|
|
|
generateSplicesForMkScope,
|
|
|
|
makeScopeWithSplicing',
|
|
|
|
stdenv,
|
|
|
|
preLibcCrossHeaders,
|
|
|
|
config,
|
|
|
|
path,
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
# Prefix for binaries. Customarily ends with a dash separator.
|
|
|
|
#
|
|
|
|
# TODO(@Ericson2314) Make unconditional, or optional but always true by
|
|
|
|
# default.
|
|
|
|
targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) (
|
|
|
|
stdenv.targetPlatform.config + "-"
|
|
|
|
);
|
|
|
|
|
|
|
|
# Bootstrap `fetchurl` needed to build SDK packages without causing an infinite recursion.
|
|
|
|
fetchurlBoot = import (path + "/pkgs/build-support/fetchurl/boot.nix") { inherit (stdenv) system; };
|
|
|
|
|
|
|
|
aliases = self: super: { }; # lib.optionalAttrs config.allowAliases (import ../top-level/darwin-aliases.nix lib self super pkgs);
|
|
|
|
in
|
|
|
|
|
|
|
|
makeScopeWithSplicing' {
|
|
|
|
otherSplices = generateSplicesForMkScope "darwin";
|
|
|
|
extra = spliced: spliced.apple_sdk.frameworks;
|
|
|
|
f = lib.extends aliases (
|
|
|
|
self:
|
|
|
|
let
|
|
|
|
inherit (self) mkDerivation callPackage;
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# Must use pkgs.callPackage to avoid infinite recursion.
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# Open source packages that are built from source
|
|
|
|
appleSourcePackages = pkgs.callPackage ./packages/apple-source-releases { } self;
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
impure-cmds = pkgs.callPackage ./packages/impure-cmds { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# macOS 10.12 SDK
|
|
|
|
apple_sdk_10_12 = pkgs.callPackage ./packages/apple-sdk {
|
|
|
|
inherit (buildPackages.darwin) print-reexports;
|
|
|
|
inherit (self) darwin-stubs;
|
|
|
|
fetchurl = fetchurlBoot;
|
|
|
|
};
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# macOS 11.0 SDK
|
|
|
|
apple_sdk_11_0 = pkgs.callPackage ./packages/apple-sdk-11.0 { fetchurl = fetchurlBoot; };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# Pick an SDK
|
|
|
|
apple_sdk = if stdenv.hostPlatform.isAarch64 then apple_sdk_11_0 else apple_sdk_10_12;
|
|
|
|
|
|
|
|
# Pick the source of libraries: either Apple's open source releases, or the
|
2024-06-30 08:16:52 +00:00
|
|
|
# SDK.
|
2024-05-02 00:46:19 +00:00
|
|
|
useAppleSDKLibs = stdenv.hostPlatform.isAarch64;
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
selectAttrs =
|
|
|
|
attrs: names:
|
|
|
|
lib.listToAttrs (
|
|
|
|
lib.concatMap (n: lib.optionals (attrs ? "${n}") [ (lib.nameValuePair n attrs."${n}") ]) names
|
2024-06-30 08:16:52 +00:00
|
|
|
);
|
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
chooseLibs =
|
2024-06-30 08:16:52 +00:00
|
|
|
(
|
2024-05-02 00:46:19 +00:00
|
|
|
# There are differences in which libraries are exported. Avoid evaluation
|
|
|
|
# errors when a package is not provided.
|
|
|
|
selectAttrs (if useAppleSDKLibs then apple_sdk else appleSourcePackages) [
|
|
|
|
"Libsystem"
|
|
|
|
"LibsystemCross"
|
|
|
|
"libcharset"
|
|
|
|
"libunwind"
|
2024-06-30 08:16:52 +00:00
|
|
|
"objc4"
|
2024-05-02 00:46:19 +00:00
|
|
|
"configd"
|
2024-06-30 08:16:52 +00:00
|
|
|
"IOKit"
|
|
|
|
]
|
|
|
|
)
|
2024-05-02 00:46:19 +00:00
|
|
|
// {
|
|
|
|
inherit (if useAppleSDKLibs then apple_sdk.frameworks else appleSourcePackages) Security;
|
|
|
|
};
|
2024-06-30 08:16:52 +00:00
|
|
|
in
|
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
impure-cmds
|
|
|
|
// appleSourcePackages
|
|
|
|
// chooseLibs
|
2024-06-30 08:16:52 +00:00
|
|
|
// {
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
inherit apple_sdk apple_sdk_10_12 apple_sdk_11_0;
|
|
|
|
|
|
|
|
stdenvNoCF = stdenv.override { extraBuildInputs = [ ]; };
|
|
|
|
|
|
|
|
binutils-unwrapped = callPackage ./packages/binutils {
|
|
|
|
inherit (pkgs) binutils-unwrapped;
|
|
|
|
inherit (pkgs.llvmPackages) llvm clang-unwrapped;
|
2024-06-30 08:16:52 +00:00
|
|
|
};
|
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
binutils = pkgs.wrapBintoolsWith {
|
|
|
|
libc = if stdenv.targetPlatform != stdenv.hostPlatform then pkgs.libcCross else pkgs.stdenv.cc.libc;
|
|
|
|
bintools = self.binutils-unwrapped;
|
2024-06-30 08:16:52 +00:00
|
|
|
};
|
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
binutilsDualAs-unwrapped = callPackage ./packages/binutils {
|
|
|
|
inherit (pkgs) binutils-unwrapped;
|
|
|
|
inherit (pkgs.llvmPackages) llvm clang-unwrapped;
|
|
|
|
dualAs = true;
|
|
|
|
};
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
binutilsDualAs = pkgs.wrapBintoolsWith {
|
|
|
|
libc = if stdenv.targetPlatform != stdenv.hostPlatform then pkgs.libcCross else pkgs.stdenv.cc.libc;
|
|
|
|
bintools = self.binutilsDualAs-unwrapped;
|
2024-06-30 08:16:52 +00:00
|
|
|
};
|
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
binutilsNoLibc = pkgs.wrapBintoolsWith {
|
|
|
|
libc = preLibcCrossHeaders;
|
|
|
|
bintools = self.binutils-unwrapped;
|
2024-06-30 08:16:52 +00:00
|
|
|
};
|
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
cctools = self.cctools-llvm;
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
cctools-apple = callPackage ./packages/cctools/apple.nix {
|
|
|
|
stdenv = if stdenv.isDarwin then stdenv else pkgs.libcxxStdenv;
|
2024-06-30 08:16:52 +00:00
|
|
|
};
|
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
cctools-llvm = callPackage ./packages/cctools/llvm.nix {
|
|
|
|
stdenv = if stdenv.isDarwin then stdenv else pkgs.libcxxStdenv;
|
2024-06-30 08:16:52 +00:00
|
|
|
};
|
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
cctools-port = callPackage ./packages/cctools/port.nix {
|
|
|
|
stdenv = if stdenv.isDarwin then stdenv else pkgs.libcxxStdenv;
|
2024-06-30 08:16:52 +00:00
|
|
|
};
|
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# TODO(@connorbaker): See https://github.com/NixOS/nixpkgs/issues/229389.
|
|
|
|
cf-private = self.apple_sdk.frameworks.CoreFoundation;
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
DarwinTools = callPackage ./packages/DarwinTools { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
darwin-stubs = callPackage ./packages/darwin-stubs { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
print-reexports = callPackage ./packages/print-reexports { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
rewrite-tbd = callPackage ./packages/rewrite-tbd { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
checkReexportsHook = pkgs.makeSetupHook {
|
|
|
|
name = "darwin-check-reexports-hook";
|
|
|
|
propagatedBuildInputs = [ pkgs.darwin.print-reexports ];
|
|
|
|
} ./packages/print-reexports/setup-hook.sh;
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
sigtool = callPackage ./packages/sigtool { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
signingUtils = callPackage ./packages/signing-utils { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
postLinkSignHook = callPackage ./packages/signing-utils/post-link-sign-hook.nix { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
autoSignDarwinBinariesHook = pkgs.makeSetupHook {
|
|
|
|
name = "auto-sign-darwin-binaries-hook";
|
|
|
|
propagatedBuildInputs = [ self.signingUtils ];
|
|
|
|
} ./packages/signing-utils/auto-sign-hook.sh;
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
iosSdkPkgs = callPackage ./packages/xcode/sdk-pkgs.nix {
|
|
|
|
buildIosSdk = buildPackages.darwin.iosSdkPkgs.sdk;
|
|
|
|
targetIosSdkPkgs = targetPackages.darwin.iosSdkPkgs;
|
|
|
|
inherit (pkgs.llvmPackages) clang-unwrapped;
|
2024-06-30 08:16:52 +00:00
|
|
|
};
|
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
iproute2mac = callPackage ./packages/iproute2mac { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
libobjc = self.objc4;
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
lsusb = callPackage ./packages/lsusb { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
moltenvk = pkgs.darwin.apple_sdk_11_0.callPackage ./packages/moltenvk {
|
|
|
|
inherit (apple_sdk_11_0.frameworks)
|
2024-06-30 08:16:52 +00:00
|
|
|
AppKit
|
2024-05-02 00:46:19 +00:00
|
|
|
Foundation
|
2024-06-30 08:16:52 +00:00
|
|
|
Metal
|
2024-05-02 00:46:19 +00:00
|
|
|
QuartzCore
|
2024-06-30 08:16:52 +00:00
|
|
|
;
|
2024-05-02 00:46:19 +00:00
|
|
|
inherit (apple_sdk_11_0.libs) simd;
|
2024-06-30 08:16:52 +00:00
|
|
|
};
|
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
openwith = pkgs.darwin.apple_sdk_11_0.callPackage ./packages/openwith {
|
|
|
|
inherit (apple_sdk_11_0.frameworks) AppKit Foundation UniformTypeIdentifiers;
|
2024-06-30 08:16:52 +00:00
|
|
|
};
|
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
stubs = pkgs.callPackages ./packages/stubs { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
trash = callPackage ./packages/trash { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
xattr = pkgs.python3Packages.callPackage ./packages/xattr { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
inherit (pkgs.callPackages ./packages/xcode { })
|
|
|
|
xcode_8_1
|
|
|
|
xcode_8_2
|
|
|
|
xcode_9_1
|
|
|
|
xcode_9_2
|
|
|
|
xcode_9_3
|
|
|
|
xcode_9_4
|
|
|
|
xcode_9_4_1
|
|
|
|
xcode_10_1
|
|
|
|
xcode_10_2
|
|
|
|
xcode_10_2_1
|
|
|
|
xcode_10_3
|
2024-06-30 08:16:52 +00:00
|
|
|
xcode_11
|
2024-05-02 00:46:19 +00:00
|
|
|
xcode_11_1
|
|
|
|
xcode_11_2
|
|
|
|
xcode_11_3_1
|
|
|
|
xcode_11_4
|
|
|
|
xcode_11_5
|
|
|
|
xcode_11_6
|
|
|
|
xcode_11_7
|
2024-06-30 08:16:52 +00:00
|
|
|
xcode_12
|
2024-05-02 00:46:19 +00:00
|
|
|
xcode_12_0_1
|
|
|
|
xcode_12_1
|
|
|
|
xcode_12_2
|
|
|
|
xcode_12_3
|
|
|
|
xcode_12_4
|
|
|
|
xcode_12_5
|
|
|
|
xcode_12_5_1
|
2024-06-30 08:16:52 +00:00
|
|
|
xcode_13
|
2024-05-02 00:46:19 +00:00
|
|
|
xcode_13_1
|
|
|
|
xcode_13_2
|
|
|
|
xcode_13_3
|
|
|
|
xcode_13_3_1
|
|
|
|
xcode_13_4
|
|
|
|
xcode_13_4_1
|
2024-06-30 08:16:52 +00:00
|
|
|
xcode_14
|
2024-05-02 00:46:19 +00:00
|
|
|
xcode_14_1
|
2024-06-30 08:16:52 +00:00
|
|
|
xcode_15
|
2024-05-02 00:46:19 +00:00
|
|
|
xcode_15_1
|
2024-06-30 08:16:52 +00:00
|
|
|
xcode
|
|
|
|
;
|
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
CoreSymbolication = callPackage ./packages/CoreSymbolication { inherit (apple_sdk) darwin-stubs; };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# TODO: Remove the CF hook if a solution to the crashes is not found.
|
2024-06-30 08:16:52 +00:00
|
|
|
CF =
|
2024-05-02 00:46:19 +00:00
|
|
|
# CF used to refer to the open source version of CoreFoundation from the Swift
|
|
|
|
# project. As of macOS 14, the rpath-based approach allowing packages to choose
|
|
|
|
# which version to use no longer seems to work reliably. Sometimes they works,
|
|
|
|
# but sometimes they crash with the error (in the system crash logs):
|
|
|
|
# CF objects must have a non-zero isa.
|
|
|
|
# See https://developer.apple.com/forums/thread/739355 for more on that error.
|
2024-06-30 08:16:52 +00:00
|
|
|
#
|
2024-05-02 00:46:19 +00:00
|
|
|
# In this branch, we only have a single "CoreFoundation" to choose from.
|
|
|
|
# To be compatible with the existing convention, we define
|
|
|
|
# CoreFoundation with the setup hook, and CF as the same package but
|
|
|
|
# with the setup hook removed.
|
2024-06-30 08:16:52 +00:00
|
|
|
#
|
2024-05-02 00:46:19 +00:00
|
|
|
# This may seem unimportant, but without it packages (e.g., bacula) will
|
|
|
|
# fail with linker errors referring ___CFConstantStringClassReference.
|
|
|
|
# It's not clear to me why some packages need this extra setup.
|
|
|
|
lib.overrideDerivation apple_sdk.frameworks.CoreFoundation (drv: {
|
|
|
|
setupHook = null;
|
|
|
|
});
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# Formerly the CF attribute. Use this is you need the open source release.
|
|
|
|
swift-corelibs-foundation = callPackage ./packages/swift-corelibs/corefoundation.nix { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# As the name says, this is broken, but I don't want to lose it since it's a direction we want to go in
|
|
|
|
# libdispatch-broken = callPackage ./packages/swift-corelibs/libdispatch.nix { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
libtapi = callPackage ./packages/libtapi { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
ios-deploy = callPackage ./packages/ios-deploy { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
discrete-scroll = callPackage ./packages/discrete-scroll { };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# # See doc/packages/darwin-builder.section.md
|
|
|
|
# linux-builder = lib.makeOverridable ({ modules }:
|
2024-06-30 08:16:52 +00:00
|
|
|
# let
|
2024-05-02 00:46:19 +00:00
|
|
|
# toGuest = builtins.replaceStrings [ "darwin" ] [ "linux" ];
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# nixos = import ../../nixos {
|
|
|
|
# configuration = {
|
|
|
|
# imports = [
|
|
|
|
# ../../nixos/modules/profiles/macos-builder.nix
|
|
|
|
# ] ++ modules;
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# # If you need to override this, consider starting with the right Nixpkgs
|
|
|
|
# # in the first place, ie change `pkgs` in `pkgs.darwin.linux-builder`.
|
|
|
|
# # or if you're creating new wiring that's not `pkgs`-centric, perhaps use the
|
|
|
|
# # macos-builder profile directly.
|
|
|
|
# virtualisation.host = { inherit pkgs; };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# nixpkgs.hostPlatform = lib.mkDefault (toGuest stdenv.hostPlatform.system);
|
2024-06-30 08:16:52 +00:00
|
|
|
# };
|
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# system = null;
|
|
|
|
# };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# in
|
|
|
|
# nixos.config.system.build.macos-builder-installer) { modules = [ ]; };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
# linux-builder-x86_64 = self.linux-builder.override {
|
|
|
|
# modules = [ { nixpkgs.hostPlatform = "x86_64-linux"; } ];
|
|
|
|
# };
|
2024-06-30 08:16:52 +00:00
|
|
|
|
2024-05-02 00:46:19 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|