2 , buildPackages, pkgs, targetPackages
3 , pkgsBuildBuild, pkgsBuildHost, pkgsBuildTarget, pkgsHostHost, pkgsTargetTarget
4 , stdenv, splicePackages, newScope
10 selfBuildBuild = pkgsBuildBuild.darwin;
11 selfBuildHost = pkgsBuildHost.darwin;
12 selfBuildTarget = pkgsBuildTarget.darwin;
13 selfHostHost = pkgsHostHost.darwin;
14 selfTargetTarget = pkgsTargetTarget.darwin or {}; # might be missing
17 # Prefix for binaries. Customarily ends with a dash separator.
19 # TODO(@Ericson2314) Make unconditional, or optional but always true by
21 targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
22 (stdenv.targetPlatform.config + "-");
25 lib.makeScopeWithSplicing splicePackages newScope otherSplices (_: {}) (spliced: spliced.apple_sdk.frameworks) (self: let
26 inherit (self) mkDerivation callPackage;
28 # Must use pkgs.callPackage to avoid infinite recursion.
30 # Open source packages that are built from source
31 appleSourcePackages = pkgs.callPackage ../os-specific/darwin/apple-source-releases { } self;
33 impure-cmds = pkgs.callPackage ../os-specific/darwin/impure-cmds { };
36 apple_sdk_10_12 = pkgs.callPackage ../os-specific/darwin/apple-sdk {
37 inherit (buildPackages.darwin) print-reexports;
38 inherit (self) darwin-stubs;
42 apple_sdk_11_0 = pkgs.callPackage ../os-specific/darwin/apple-sdk-11.0 { };
45 apple_sdk = if stdenv.hostPlatform.isAarch64 then apple_sdk_11_0 else apple_sdk_10_12;
47 # Pick the source of libraries: either Apple's open source releases, or the
49 useAppleSDKLibs = stdenv.hostPlatform.isAarch64;
51 selectAttrs = attrs: names:
52 lib.listToAttrs (lib.concatMap (n: if attrs ? "${n}" then [(lib.nameValuePair n attrs."${n}")] else []) names);
55 # There are differences in which libraries are exported. Avoid evaluation
56 # errors when a package is not provided.
60 else appleSourcePackages
61 ) ["Libsystem" "LibsystemCross" "libcharset" "libunwind" "objc4" "configd" "IOKit"]
65 then apple_sdk.frameworks
66 else appleSourcePackages
71 impure-cmds // appleSourcePackages // chooseLibs // {
73 inherit apple_sdk apple_sdk_10_12 apple_sdk_11_0;
75 stdenvNoCF = stdenv.override {
76 extraBuildInputs = [];
79 binutils-unwrapped = callPackage ../os-specific/darwin/binutils {
80 inherit (pkgs) binutils-unwrapped;
81 inherit (pkgs.llvmPackages) llvm clang-unwrapped;
84 binutils = pkgs.wrapBintoolsWith {
86 if stdenv.targetPlatform != stdenv.hostPlatform
88 else pkgs.stdenv.cc.libc;
89 bintools = self.binutils-unwrapped;
92 binutilsNoLibc = pkgs.wrapBintoolsWith {
93 libc = preLibcCrossHeaders;
94 bintools = self.binutils-unwrapped;
97 cctools = callPackage ../os-specific/darwin/cctools/port.nix {
98 stdenv = if stdenv.isDarwin then stdenv else pkgs.libcxxStdenv;
101 # TODO: remove alias.
102 cf-private = self.apple_sdk.frameworks.CoreFoundation;
104 DarwinTools = callPackage ../os-specific/darwin/DarwinTools { };
106 darwin-stubs = callPackage ../os-specific/darwin/darwin-stubs { };
108 print-reexports = callPackage ../os-specific/darwin/print-reexports { };
110 rewrite-tbd = callPackage ../os-specific/darwin/rewrite-tbd { };
112 checkReexportsHook = pkgs.makeSetupHook {
113 deps = [ pkgs.darwin.print-reexports ];
114 } ../os-specific/darwin/print-reexports/setup-hook.sh;
116 sigtool = callPackage ../os-specific/darwin/sigtool { };
118 postLinkSignHook = pkgs.writeTextFile {
119 name = "post-link-sign-hook";
123 if [ "$linkerOutput" != "/dev/null" ]; then
124 CODESIGN_ALLOCATE=${targetPrefix}codesign_allocate \
125 ${self.sigtool}/bin/codesign -f -s - "$linkerOutput"
130 signingUtils = callPackage ../os-specific/darwin/signing-utils { };
132 autoSignDarwinBinariesHook = pkgs.makeSetupHook {
133 deps = [ self.signingUtils ];
134 } ../os-specific/darwin/signing-utils/auto-sign-hook.sh;
136 maloader = callPackage ../os-specific/darwin/maloader {
139 insert_dylib = callPackage ../os-specific/darwin/insert_dylib { };
141 iosSdkPkgs = callPackage ../os-specific/darwin/xcode/sdk-pkgs.nix {
142 buildIosSdk = buildPackages.darwin.iosSdkPkgs.sdk;
143 targetIosSdkPkgs = targetPackages.darwin.iosSdkPkgs;
144 inherit (pkgs.llvmPackages) clang-unwrapped;
147 iproute2mac = callPackage ../os-specific/darwin/iproute2mac { };
149 libobjc = self.objc4;
151 lsusb = callPackage ../os-specific/darwin/lsusb { };
153 moltenvk = pkgs.darwin.apple_sdk_11_0.callPackage ../os-specific/darwin/moltenvk {
154 inherit (apple_sdk_11_0.frameworks) AppKit Foundation Metal QuartzCore;
155 inherit (apple_sdk_11_0) MacOSX-SDK Libsystem;
156 inherit (pkgs.darwin) cctools sigtool;
159 opencflite = callPackage ../os-specific/darwin/opencflite { };
161 stubs = pkgs.callPackages ../os-specific/darwin/stubs { };
163 trash = callPackage ../os-specific/darwin/trash { };
165 xattr = pkgs.python3Packages.callPackage ../os-specific/darwin/xattr { };
167 inherit (pkgs.callPackages ../os-specific/darwin/xcode { })
169 xcode_9_1 xcode_9_2 xcode_9_4 xcode_9_4_1
170 xcode_10_2 xcode_10_2_1 xcode_10_3
174 CoreSymbolication = callPackage ../os-specific/darwin/CoreSymbolication { };
176 # TODO: make swift-corefoundation build with apple_sdk_11_0.Libsystem
177 CF = if useAppleSDKLibs
179 # This attribute (CF) is included in extraBuildInputs in the stdenv. This
180 # is typically the open source project. When a project refers to
181 # "CoreFoundation" it has an extra setup hook to force impure system
182 # CoreFoundation into the link step.
184 # In this branch, we only have a single "CoreFoundation" to choose from.
185 # To be compatible with the existing convention, we define
186 # CoreFoundation with the setup hook, and CF as the same package but
187 # with the setup hook removed.
189 # This may seem unimportant, but without it packages (e.g., bacula) will
190 # fail with linker errors referring ___CFConstantStringClassReference.
191 # It's not clear to me why some packages need this extra setup.
192 lib.overrideDerivation apple_sdk.frameworks.CoreFoundation (drv: {
195 else callPackage ../os-specific/darwin/swift-corelibs/corefoundation.nix { };
197 # 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
198 # libdispatch-broken = callPackage ../os-specific/darwin/swift-corelibs/libdispatch.nix { };
200 darling = callPackage ../os-specific/darwin/darling/default.nix { };
202 libtapi = callPackage ../os-specific/darwin/libtapi {};
204 ios-deploy = callPackage ../os-specific/darwin/ios-deploy {};
206 discrete-scroll = callPackage ../os-specific/darwin/discrete-scroll { };