2 , buildPackages, pkgs, targetPackages
3 , generateSplicesForMkScope, makeScopeWithSplicing'
10 # Prefix for binaries. Customarily ends with a dash separator.
12 # TODO(@Ericson2314) Make unconditional, or optional but always true by
14 targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
15 (stdenv.targetPlatform.config + "-");
17 # Bootstrap `fetchurl` needed to build SDK packages without causing an infinite recursion.
18 fetchurlBoot = import ../build-support/fetchurl/boot.nix {
19 inherit (stdenv) system;
22 aliases = self: super: lib.optionalAttrs config.allowAliases (import ../top-level/darwin-aliases.nix lib self super pkgs);
26 stdenv.override (old: {
27 extraBuildInputs = map (
29 if lib.isDerivation pkg && lib.getName pkg == "apple-sdk" then
30 pkg.override { enableBootstrap = true; }
33 ) (old.extraBuildInputs or [ ]);
36 mkStub = pkgs.callPackage ../os-specific/darwin/apple-sdk/mk-stub.nix { };
39 makeScopeWithSplicing' {
40 otherSplices = generateSplicesForMkScope "darwin";
41 extra = spliced: spliced.apple_sdk.frameworks;
42 f = lib.extends aliases (self: let
43 inherit (self) mkDerivation callPackage;
45 # Open source packages that are built from source
46 apple-source-packages = lib.packagesFromDirectoryRecursive {
47 callPackage = self.callPackage;
48 directory = ../os-specific/darwin/apple-source-releases;
51 # Compatibility packages that aren’t necessary anymore
52 apple-source-headers = {
53 libresolvHeaders = lib.getDev self.libresolv;
54 libutilHeaders = lib.getDev self.libutil;
57 # Must use pkgs.callPackage to avoid infinite recursion.
58 impure-cmds = pkgs.callPackage ../os-specific/darwin/impure-cmds { };
61 apple_sdk_10_12 = pkgs.callPackage ../os-specific/darwin/apple-sdk { };
64 apple_sdk_11_0 = pkgs.callPackage ../os-specific/darwin/apple-sdk-11.0 { };
67 apple_sdk_12_3 = pkgs.callPackage ../os-specific/darwin/apple-sdk-12.3 { };
71 "10.12" = apple_sdk_10_12;
72 "11.0" = apple_sdk_11_0;
73 }.${stdenv.hostPlatform.darwinSdkVersion}
74 or (throw "Unsupported sdk: ${stdenv.hostPlatform.darwinSdkVersion}");
77 inherit apple_sdk apple_sdk_10_12 apple_sdk_11_0 apple_sdk_12_3;
112 ] (mkStub apple_sdk.version);
115 impure-cmds // apple-source-packages // apple-source-headers // stubs // {
117 stdenvNoCF = stdenv.override {
118 extraBuildInputs = [];
121 inherit (self.adv_cmds) ps;
123 binutils-unwrapped = callPackage ../os-specific/darwin/binutils {
124 inherit (pkgs) cctools;
125 inherit (pkgs.llvmPackages) clang-unwrapped llvm llvm-manpages;
128 binutils = pkgs.wrapBintoolsWith {
130 if stdenv.targetPlatform != stdenv.hostPlatform
132 else pkgs.stdenv.cc.libc;
133 bintools = self.binutils-unwrapped;
136 # x86-64 Darwin gnat-bootstrap emits assembly
137 # with MOVQ as the mnemonic for quadword interunit moves
138 # such as `movq %rbp, %xmm0`.
139 # The clang integrated assembler recognises this as valid,
140 # but unfortunately the cctools.gas GNU assembler does not;
141 # it instead uses MOVD as the mnemonic.
142 # The assembly that a GCC build emits is determined at build time
143 # and cannot be changed afterwards.
145 # To build GNAT on x86-64 Darwin, therefore,
146 # we need both the clang _and_ the cctools.gas assemblers to be available:
147 # the former to build at least the stage1 compiler,
148 # and the latter at least to be detectable
149 # as the target for the final compiler.
150 binutilsDualAs-unwrapped = pkgs.buildEnv {
151 name = "${lib.getName self.binutils-unwrapped}-dualas-${lib.getVersion self.binutils-unwrapped}";
153 self.binutils-unwrapped
154 (lib.getOutput "gas" pkgs.cctools)
158 binutilsDualAs = self.binutils.override {
159 bintools = self.binutilsDualAs-unwrapped;
162 binutilsNoLibc = pkgs.wrapBintoolsWith {
163 libc = preLibcCrossHeaders;
164 bintools = self.binutils-unwrapped;
167 # Removes propagated packages from the stdenv, so those packages can be built without depending upon themselves.
168 bootstrapStdenv = mkBootstrapStdenv pkgs.stdenv;
170 libSystem = callPackage ../os-specific/darwin/libSystem { };
172 # TODO(@connorbaker): See https://github.com/NixOS/nixpkgs/issues/229389.
173 cf-private = self.apple_sdk.frameworks.CoreFoundation;
175 DarwinTools = callPackage ../os-specific/darwin/DarwinTools { };
177 print-reexports = callPackage ../os-specific/darwin/print-reexports { };
179 rewrite-tbd = callPackage ../os-specific/darwin/rewrite-tbd { };
181 checkReexportsHook = pkgs.makeSetupHook {
182 name = "darwin-check-reexports-hook";
183 propagatedBuildInputs = [ pkgs.darwin.print-reexports ];
184 } ../os-specific/darwin/print-reexports/setup-hook.sh;
186 libunwind = callPackage ../os-specific/darwin/libunwind { };
188 sigtool = callPackage ../os-specific/darwin/sigtool { };
190 signingUtils = callPackage ../os-specific/darwin/signing-utils { };
192 postLinkSignHook = callPackage ../os-specific/darwin/signing-utils/post-link-sign-hook.nix { };
194 autoSignDarwinBinariesHook = pkgs.makeSetupHook {
195 name = "auto-sign-darwin-binaries-hook";
196 propagatedBuildInputs = [ self.signingUtils ];
197 } ../os-specific/darwin/signing-utils/auto-sign-hook.sh;
199 iosSdkPkgs = callPackage ../os-specific/darwin/xcode/sdk-pkgs.nix {
200 buildIosSdk = buildPackages.darwin.iosSdkPkgs.sdk;
201 targetIosSdkPkgs = targetPackages.darwin.iosSdkPkgs;
202 inherit (pkgs.llvmPackages) clang-unwrapped;
205 iproute2mac = callPackage ../os-specific/darwin/iproute2mac { };
207 lsusb = callPackage ../os-specific/darwin/lsusb { };
209 openwith = callPackage ../os-specific/darwin/openwith { };
211 stubs = pkgs.callPackages ../os-specific/darwin/stubs { };
213 trash = callPackage ../os-specific/darwin/trash { };
215 inherit (self.file_cmds) xattr;
217 inherit (pkgs.callPackages ../os-specific/darwin/xcode { })
219 xcode_9_1 xcode_9_2 xcode_9_3 xcode_9_4 xcode_9_4_1
220 xcode_10_1 xcode_10_2 xcode_10_2_1 xcode_10_3
221 xcode_11 xcode_11_1 xcode_11_2 xcode_11_3_1 xcode_11_4 xcode_11_5 xcode_11_6 xcode_11_7
222 xcode_12 xcode_12_0_1 xcode_12_1 xcode_12_2 xcode_12_3 xcode_12_4 xcode_12_5 xcode_12_5_1
223 xcode_13 xcode_13_1 xcode_13_2 xcode_13_3 xcode_13_3_1 xcode_13_4 xcode_13_4_1
225 xcode_15 xcode_15_0_1 xcode_15_1 xcode_15_2 xcode_15_3 xcode_15_4
229 xcodeProjectCheckHook = pkgs.makeSetupHook {
230 name = "xcode-project-check-hook";
231 propagatedBuildInputs = [ pkgs.pkgsBuildHost.openssl ];
232 } ../os-specific/darwin/xcode-project-check-hook/setup-hook.sh;
234 # Formerly the CF attribute. Use this is you need the open source release.
235 swift-corelibs-foundation = callPackage ../os-specific/darwin/swift-corelibs/corefoundation.nix { };
237 # 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
238 # libdispatch-broken = callPackage ../os-specific/darwin/swift-corelibs/libdispatch.nix { };
240 # See doc/packages/darwin-builder.section.md
241 linux-builder = lib.makeOverridable ({ modules }:
243 toGuest = builtins.replaceStrings [ "darwin" ] [ "linux" ];
245 nixos = import ../../nixos {
248 ../../nixos/modules/profiles/nix-builder-vm.nix
251 # If you need to override this, consider starting with the right Nixpkgs
252 # in the first place, ie change `pkgs` in `pkgs.darwin.linux-builder`.
253 # or if you're creating new wiring that's not `pkgs`-centric, perhaps use the
254 # macos-builder profile directly.
255 virtualisation.host = { inherit pkgs; };
257 nixpkgs.hostPlatform = lib.mkDefault (toGuest stdenv.hostPlatform.system);
264 nixos.config.system.build.macos-builder-installer) { modules = [ ]; };
266 linux-builder-x86_64 = self.linux-builder.override {
267 modules = [ { nixpkgs.hostPlatform = "x86_64-linux"; } ];