Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 buildPackages,
4 pkgs,
5 targetPackages,
6 generateSplicesForMkScope,
7 makeScopeWithSplicing',
8 stdenv,
9 config,
10}:
11
12let
13 aliases =
14 self: super:
15 lib.optionalAttrs config.allowAliases (import ../top-level/darwin-aliases.nix lib self super pkgs);
16
17 mkBootstrapStdenv =
18 stdenv:
19 stdenv.override (old: {
20 extraBuildInputs = map (
21 pkg:
22 if lib.isDerivation pkg && lib.getName pkg == "apple-sdk" then
23 pkg.override { enableBootstrap = true; }
24 else
25 pkg
26 ) (old.extraBuildInputs or [ ]);
27 });
28in
29
30makeScopeWithSplicing' {
31 otherSplices = generateSplicesForMkScope "darwin";
32 f = lib.extends aliases (
33 self:
34 let
35 inherit (self) mkDerivation callPackage;
36
37 # Open source packages that are built from source
38 apple-source-packages = lib.packagesFromDirectoryRecursive {
39 callPackage = self.callPackage;
40 directory = ../os-specific/darwin/apple-source-releases;
41 };
42
43 # Must use pkgs.callPackage to avoid infinite recursion.
44 impure-cmds = pkgs.callPackage ../os-specific/darwin/impure-cmds { };
45 in
46
47 impure-cmds
48 // apple-source-packages
49 // {
50
51 inherit (self.adv_cmds) ps;
52
53 binutils-unwrapped = callPackage ../os-specific/darwin/binutils {
54 inherit (pkgs) cctools;
55 inherit (pkgs.llvmPackages) clang-unwrapped llvm llvm-manpages;
56 };
57
58 binutils = pkgs.wrapBintoolsWith {
59 inherit (targetPackages) libc;
60 bintools = self.binutils-unwrapped;
61 };
62
63 # x86-64 Darwin gnat-bootstrap emits assembly
64 # with MOVQ as the mnemonic for quadword interunit moves
65 # such as `movq %rbp, %xmm0`.
66 # The clang integrated assembler recognises this as valid,
67 # but unfortunately the cctools.gas GNU assembler does not;
68 # it instead uses MOVD as the mnemonic.
69 # The assembly that a GCC build emits is determined at build time
70 # and cannot be changed afterwards.
71 #
72 # To build GNAT on x86-64 Darwin, therefore,
73 # we need both the clang _and_ the cctools.gas assemblers to be available:
74 # the former to build at least the stage1 compiler,
75 # and the latter at least to be detectable
76 # as the target for the final compiler.
77 binutilsDualAs-unwrapped = pkgs.buildEnv {
78 name = "${lib.getName self.binutils-unwrapped}-dualas-${lib.getVersion self.binutils-unwrapped}";
79 paths = [
80 self.binutils-unwrapped
81 (lib.getOutput "gas" pkgs.cctools)
82 ];
83 };
84
85 binutilsDualAs = self.binutils.override {
86 bintools = self.binutilsDualAs-unwrapped;
87 };
88
89 binutilsNoLibc = pkgs.wrapBintoolsWith {
90 libc = targetPackages.preLibcHeaders;
91 bintools = self.binutils-unwrapped;
92 };
93
94 # Removes propagated packages from the stdenv, so those packages can be built without depending upon themselves.
95 bootstrapStdenv = mkBootstrapStdenv pkgs.stdenv;
96
97 libSystem = callPackage ../os-specific/darwin/libSystem { };
98
99 DarwinTools = callPackage ../os-specific/darwin/DarwinTools { };
100
101 libunwind = callPackage ../os-specific/darwin/libunwind { };
102
103 sigtool = callPackage ../os-specific/darwin/sigtool { };
104
105 signingUtils = callPackage ../os-specific/darwin/signing-utils { };
106
107 autoSignDarwinBinariesHook = pkgs.makeSetupHook {
108 name = "auto-sign-darwin-binaries-hook";
109 propagatedBuildInputs = [ self.signingUtils ];
110 } ../os-specific/darwin/signing-utils/auto-sign-hook.sh;
111
112 iosSdkPkgs = callPackage ../os-specific/darwin/xcode/sdk-pkgs.nix {
113 buildIosSdk = buildPackages.darwin.iosSdkPkgs.sdk;
114 targetIosSdkPkgs = targetPackages.darwin.iosSdkPkgs;
115 inherit (pkgs.llvmPackages) clang-unwrapped;
116 };
117
118 lsusb = callPackage ../os-specific/darwin/lsusb { };
119
120 openwith = callPackage ../os-specific/darwin/openwith { };
121
122 trash = callPackage ../os-specific/darwin/trash { };
123
124 inherit (self.file_cmds) xattr;
125
126 inherit (pkgs.callPackages ../os-specific/darwin/xcode { })
127 xcode_8_1
128 xcode_8_2
129 xcode_9_1
130 xcode_9_2
131 xcode_9_3
132 xcode_9_4
133 xcode_9_4_1
134 xcode_10_1
135 xcode_10_2
136 xcode_10_2_1
137 xcode_10_3
138 xcode_11
139 xcode_11_1
140 xcode_11_2
141 xcode_11_3_1
142 xcode_11_4
143 xcode_11_5
144 xcode_11_6
145 xcode_11_7
146 xcode_12
147 xcode_12_0_1
148 xcode_12_1
149 xcode_12_2
150 xcode_12_3
151 xcode_12_4
152 xcode_12_5
153 xcode_12_5_1
154 xcode_13
155 xcode_13_1
156 xcode_13_2
157 xcode_13_3
158 xcode_13_3_1
159 xcode_13_4
160 xcode_13_4_1
161 xcode_14
162 xcode_14_1
163 xcode_15
164 xcode_15_0_1
165 xcode_15_1
166 xcode_15_2
167 xcode_15_3
168 xcode_15_4
169 xcode_16
170 xcode_16_1
171 xcode_16_2
172 xcode_16_3
173 xcode_16_4
174 xcode
175 requireXcode
176 ;
177
178 xcodeProjectCheckHook = pkgs.makeSetupHook {
179 name = "xcode-project-check-hook";
180 propagatedBuildInputs = [ pkgs.pkgsBuildHost.openssl ];
181 } ../os-specific/darwin/xcode-project-check-hook/setup-hook.sh;
182
183 # See doc/packages/darwin-builder.section.md
184 linux-builder = lib.makeOverridable (
185 { modules }:
186 let
187 toGuest = builtins.replaceStrings [ "darwin" ] [ "linux" ];
188
189 nixos = import ../../nixos {
190 configuration = {
191 imports = [
192 ../../nixos/modules/profiles/nix-builder-vm.nix
193 ]
194 ++ modules;
195
196 # If you need to override this, consider starting with the right Nixpkgs
197 # in the first place, ie change `pkgs` in `pkgs.darwin.linux-builder`.
198 # or if you're creating new wiring that's not `pkgs`-centric, perhaps use the
199 # macos-builder profile directly.
200 virtualisation.host = { inherit pkgs; };
201
202 nixpkgs.hostPlatform = lib.mkDefault (toGuest stdenv.hostPlatform.system);
203 };
204
205 system = null;
206 };
207
208 in
209 nixos.config.system.build.macos-builder-installer
210 ) { modules = [ ]; };
211
212 linux-builder-x86_64 = self.linux-builder.override {
213 modules = [ { nixpkgs.hostPlatform = "x86_64-linux"; } ];
214 };
215
216 }
217 );
218}