git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #121654 from Ericson2314/darwin-cross-prep

treewide: Do a number of no-op cleanups for cross and darwin

commit8e84cafcd9350ce11e3f630003b859d4c70a483a authorJohn Ericson <git@JohnEricson.me> dateThu 6 May 2021, 11:38 (6 years ago) parent67c476a470640e
7 files changed+111−83
lib/customisation.nix+5−3 pkgs/development/interpreters/python/default.nix+2 pkgs/os-specific/darwin/apple-source-releases/default.nix+28−21 pkgs/stdenv/darwin/default.nix+22−22 pkgs/top-level/all-packages.nix+11−11 pkgs/top-level/darwin-packages.nix+42−25 pkgs/top-level/static.nix+1−1
lib/customisation.nix+5−3
@@ -219,16 +219,17 @@ rec {
219219
220220 /* Like the above, but aims to support cross compilation. It's still ugly, but
221221 hopefully it helps a little bit. */
222− makeScopeWithSplicing = splicePackages: newScope: otherSplices: keep: f:
222+ makeScopeWithSplicing = splicePackages: newScope: otherSplices: keep: extra: f:
223223 let
224− spliced = splicePackages {
224+ spliced0 = splicePackages {
225225 pkgsBuildBuild = otherSplices.selfBuildBuild;
226226 pkgsBuildHost = otherSplices.selfBuildHost;
227227 pkgsBuildTarget = otherSplices.selfBuildTarget;
228228 pkgsHostHost = otherSplices.selfHostHost;
229229 pkgsHostTarget = self; # Not `otherSplices.selfHostTarget`;
230230 pkgsTargetTarget = otherSplices.selfTargetTarget;
231− } // keep self;
231+ };
232+ spliced = extra spliced0 // spliced0 // keep self;
232233 self = f self // {
233234 newScope = scope: newScope (spliced // scope);
234235 callPackage = newScope spliced; # == self.newScope {};
@@ -239,6 +240,7 @@ rec {
239240 newScope
240241 otherSplices
241242 keep
243+ extra
242244 (lib.fixedPoints.extends g f);
243245 packages = f;
244246 };
pkgs/development/interpreters/python/default.nix+2
@@ -69,6 +69,7 @@ with pkgs;
6969 recursivePthLoader
7070 ;
7171 };
72+ extra = _: {};
7273 optionalExtensions = cond: as: if cond then as else [];
7374 python2Extension = import ../../../top-level/python2-packages.nix;
7475 extensions = lib.composeManyExtensions ((optionalExtensions (!self.isPy3k) [python2Extension]) ++ [ overrides ]);
@@ -77,6 +78,7 @@ with pkgs;
7778 pkgs.newScope
7879 otherSplices
7980 keep
81+ extra
8082 (lib.extends extensions pythonPackagesFun))
8183 {
8284 overrides = packageOverrides;
pkgs/os-specific/darwin/apple-source-releases/default.nix+28−21
@@ -1,9 +1,6 @@
1−{ lib, stdenv, fetchurl, fetchzip, pkgs }:
1+{ lib, stdenv, stdenvNoCC, fetchurl, fetchzip, pkgs }:
22
33let
4− macosPackages_11_0_1 = import ./macos-11.0.1.nix { inherit applePackage'; };
5− developerToolsPackages_11_3_1 = import ./developer-tools-11.3.1.nix { inherit applePackage'; };
6−
74 # This attrset can in theory be computed automatically, but for that to work nicely we need
85 # import-from-derivation to work properly. Currently it's rather ugly when we try to bootstrap
96 # a stdenv out of something like this. With some care we can probably get rid of this, but for
@@ -190,17 +187,6 @@ let
190187 }) // (attrs.meta or {});
191188 });
192189
193− applePackage' = namePath: version: sdkName: sha256: let
194− pname = builtins.head (lib.splitString "/" namePath);
195− appleDerivation = appleDerivation' pname version sdkName sha256;
196− callPackage = pkgs.newScope (packages // pkgs.darwin // { inherit appleDerivation; });
197− in callPackage (./. + "/${namePath}");
198−
199− applePackage = namePath: sdkName: sha256: let
200− pname = builtins.head (lib.splitString "/" namePath);
201− version = versions.${sdkName}.${pname};
202− in applePackage' namePath version sdkName sha256;
203−
204190 IOKitSpecs = {
205191 IOAudioFamily = fetchApple "osx-10.10.5" "0ggq7za3iq8g02j16rj67prqhrw828jsw3ah3bxq8a1cvr55aqnq";
206192 IOFireWireFamily = fetchApple "osx-10.10.5" "059qa1m668kwvchl90cqcx35b31zaqdg61zi11y1imn5s389y2g1";
@@ -225,11 +211,35 @@ let
225211
226212 IOKitSrcs = lib.mapAttrs (name: value: if lib.isFunction value then value name else value) IOKitSpecs;
227213
214+in
215+
216+# darwin package set
217+self:
218+
219+let
220+ macosPackages_11_0_1 = import ./macos-11.0.1.nix { inherit applePackage'; };
221+ developerToolsPackages_11_3_1 = import ./developer-tools-11.3.1.nix { inherit applePackage'; };
222+
223+ applePackage' = namePath: version: sdkName: sha256:
224+ let
225+ pname = builtins.head (lib.splitString "/" namePath);
226+ appleDerivation = appleDerivation' pname version sdkName sha256;
227+ callPackage = self.newScope { inherit appleDerivation; };
228+ in callPackage (./. + "/${namePath}");
229+
230+ applePackage = namePath: sdkName: sha256: let
231+ pname = builtins.head (lib.splitString "/" namePath);
232+ version = versions.${sdkName}.${pname};
233+ in applePackage' namePath version sdkName sha256;
234+
228235 # Only used for bootstrapping. It’s convenient because it was the last version to come with a real makefile.
229236 adv_cmds-boot = applePackage "adv_cmds/boot.nix" "osx-10.5.8" "102ssayxbg9wb35mdmhswbnw0bg7js3pfd8fcbic83c5q3bqa6c6" {};
230237
231− # TODO: shorten this list, we should cut down to a minimum set of bootstrap or necessary packages here.
232− stubPackages = {
238+in
239+
240+developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
241+ # TODO: shorten this list, we should cut down to a minimum set of bootstrap or necessary packages here.
242+
233243 inherit (adv_cmds-boot) ps locale;
234244 architecture = applePackage "architecture" "osx-10.11.6" "1pbpjcd7is69hn8y29i98ci0byik826if8gnp824ha92h90w0fq3" {};
235245 bsdmake = applePackage "bsdmake" "dev-tools-3.2.6" "11a9kkhz5bfgi1i8kpdkis78lhc6b5vxmhd598fcdgra1jw4iac2" {};
@@ -290,7 +300,4 @@ let
290300 # TODO(matthewbauer):
291301 # To be removed, once I figure out how to build a newer Security version.
292302 Security = applePackage "Security/boot.nix" "osx-10.9.5" "1nv0dczf67dhk17hscx52izgdcyacgyy12ag0jh6nl5hmfzsn8yy" {};
293− };
294−
295− packages = developerToolsPackages_11_3_1 // macosPackages_11_0_1 // stubPackages;
296−in packages
303+}
pkgs/stdenv/darwin/default.nix+22−22
@@ -176,13 +176,13 @@ in rec {
176176 '';
177177 };
178178
179− darwin = super.darwin // {
179+ darwin = super.darwin.overrideScope (selfDarwin: superDarwin: {
180180 Libsystem = stdenv.mkDerivation {
181181 name = "bootstrap-stage0-Libsystem";
182182 buildCommand = ''
183183 mkdir -p $out
184184
185− cp -r ${self.darwin.darwin-stubs}/usr/lib $out/lib
185+ cp -r ${selfDarwin.darwin-stubs}/usr/lib $out/lib
186186 chmod -R +w $out/lib
187187 substituteInPlace $out/lib/libSystem.B.tbd --replace /usr/lib/system $out/lib/system
188188
@@ -201,7 +201,7 @@ in rec {
201201 '';
202202 };
203203
204− darwin-stubs = super.darwin.darwin-stubs.override { inherit (self) stdenv fetchurl; };
204+ darwin-stubs = superDarwin.darwin-stubs.override { inherit (self) stdenv fetchurl; };
205205
206206 dyld = {
207207 name = "bootstrap-stage0-dyld";
@@ -220,10 +220,10 @@ in rec {
220220 nativeTools = false;
221221 nativeLibc = false;
222222 inherit (self) buildPackages coreutils gnugrep;
223− libc = self.pkgs.darwin.Libsystem;
223+ libc = selfDarwin.Libsystem;
224224 bintools = { name = "bootstrap-stage0-binutils"; outPath = bootstrapTools; };
225225 };
226− };
226+ });
227227
228228 llvmPackages_7 = {
229229 clang-unwrapped = stdenv.mkDerivation {
@@ -291,12 +291,12 @@ in rec {
291291 });
292292 in { inherit tools libraries; } // tools // libraries);
293293
294− darwin = super.darwin // {
294+ darwin = super.darwin.overrideScope (selfDarwin: _: {
295295 binutils = darwin.binutils.override {
296296 coreutils = self.coreutils;
297− libc = self.darwin.Libsystem;
297+ libc = selfDarwin.Libsystem;
298298 };
299− };
299+ });
300300 };
301301 in with prevStage; stageFun 1 prevStage {
302302 extraPreHook = "export NIX_CFLAGS_COMPILE+=\" -F${bootstrapTools}/Library/Frameworks\"";
@@ -337,11 +337,11 @@ in rec {
337337 });
338338 in { inherit tools libraries; } // tools // libraries);
339339
340− darwin = super.darwin // {
340+ darwin = super.darwin.overrideScope (_: _: {
341341 inherit (darwin)
342342 binutils dyld Libsystem xnu configd ICU libdispatch libclosure
343343 launchd CF darwin-stubs;
344− };
344+ });
345345 };
346346 in with prevStage; stageFun 2 prevStage {
347347 extraPreHook = ''
@@ -382,11 +382,11 @@ in rec {
382382 });
383383 in { inherit libraries; } // libraries);
384384
385− darwin = super.darwin // {
385+ darwin = super.darwin.overrideScope (_: _: {
386386 inherit (darwin)
387387 dyld Libsystem xnu configd libdispatch libclosure launchd libiconv
388388 locale darwin-stubs;
389− };
389+ });
390390 };
391391 in with prevStage; stageFun 3 prevStage {
392392 shell = "${pkgs.bash}/bin/bash";
@@ -442,14 +442,14 @@ in rec {
442442 });
443443 in { inherit tools libraries; } // tools // libraries);
444444
445− darwin = super.darwin // rec {
445+ darwin = super.darwin.overrideScope (_: superDarwin: {
446446 inherit (darwin) dyld Libsystem libiconv locale darwin-stubs;
447447
448− CF = super.darwin.CF.override {
448+ CF = superDarwin.CF.override {
449449 inherit libxml2;
450450 python3 = prevStage.python3;
451451 };
452− };
452+ });
453453 };
454454 in with prevStage; stageFun 4 prevStage {
455455 shell = "${pkgs.bash}/bin/bash";
@@ -480,11 +480,11 @@ in rec {
480480 });
481481 in { inherit tools libraries; } // tools // libraries);
482482
483− darwin = super.darwin // {
483+ darwin = super.darwin.overrideScope (_: _: {
484484 inherit (darwin) dyld ICU Libsystem libiconv;
485485 } // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) {
486486 inherit (darwin) binutils binutils-unwrapped cctools;
487− };
487+ });
488488 } // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) {
489489 # Need to get rid of these when cross-compiling.
490490 inherit binutils binutils-unwrapped;
@@ -537,14 +537,14 @@ in rec {
537537 ]);
538538
539539 overrides = lib.composeExtensions persistent (self: super: {
540+ darwin = super.darwin.overrideScope (_: superDarwin: {
541+ inherit (prevStage.darwin) CF darwin-stubs;
542+ xnu = superDarwin.xnu.override { inherit (prevStage) python3; };
543+ });
544+ } // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) {
540545 clang = cc;
541546 llvmPackages = super.llvmPackages // { clang = cc; };
542547 inherit cc;
543−
544− darwin = super.darwin // {
545− inherit (prevStage.darwin) CF darwin-stubs;
546− xnu = super.darwin.xnu.override { inherit (prevStage) python3; };
547− };
548548 });
549549 };
550550
pkgs/top-level/all-packages.nix+11−11
@@ -10395,15 +10395,7 @@ in
1039510395 # The GCC used to build libc for the target platform. Normal gccs will be
1039610396 # built with, and use, that cross-compiled libc.
1039710397 gccCrossStageStatic = assert stdenv.targetPlatform != stdenv.hostPlatform; let
10398− libcCross1 =
10399− if stdenv.targetPlatform.libc == "msvcrt" then targetPackages.windows.mingw_w64_headers
10400− else if stdenv.targetPlatform.libc == "libSystem" then darwin.xcode
10401− else if stdenv.targetPlatform.libc == "nblibc" then netbsd.headers
10402− else null;
10403− binutils1 = wrapBintoolsWith {
10404− bintools = binutils-unwrapped;
10405− libc = libcCross1;
10406− };
10398+ libcCross1 = binutilsNoLibc.libc;
1040710399 in wrapCCWith {
1040810400 cc = gccFun {
1040910401 # copy-pasted
@@ -10416,10 +10408,10 @@ in
1041610408 crossStageStatic = true;
1041710409 langCC = false;
1041810410 libcCross = libcCross1;
10419− targetPackages.stdenv.cc.bintools = binutils1;
10411+ targetPackages.stdenv.cc.bintools = binutilsNoLibc;
1042010412 enableShared = false;
1042110413 };
10422− bintools = binutils1;
10414+ bintools = binutilsNoLibc;
1042310415 libc = libcCross1;
1042410416 extraPackages = [];
1042510417 };
@@ -12532,6 +12524,14 @@ in
1253212524 gold = false;
1253312525 };
1253412526 });
12527+ binutilsNoLibc = wrapBintoolsWith {
12528+ bintools = binutils-unwrapped;
12529+ libc =
12530+ /**/ if stdenv.targetPlatform.libc == "msvcrt" then targetPackages.windows.mingw_w64_headers
12531+ else if stdenv.targetPlatform.libc == "libSystem" then darwin.xcode
12532+ else if stdenv.targetPlatform.libc == "nblibc" then targetPackages.netbsdCross.headers
12533+ else null;
12534+ };
1253512535
1253612536 bison = callPackage ../development/tools/parsing/bison { };
1253712537
pkgs/top-level/darwin-packages.nix+42−25
@@ -1,27 +1,44 @@
1−{ buildPackages, pkgs, targetPackages
2−, darwin, stdenv, callPackage, callPackages, newScope
1+{ lib
2+, buildPackages, pkgs, targetPackages
3+, pkgsBuildBuild, pkgsBuildHost, pkgsBuildTarget, pkgsHostHost, pkgsTargetTarget
4+, stdenv, splicePackages, newScope
35}:
46
57let
6− apple-source-releases = callPackage ../os-specific/darwin/apple-source-releases { };
8+ otherSplices = {
9+ selfBuildBuild = pkgsBuildBuild.darwin;
10+ selfBuildHost = pkgsBuildHost.darwin;
11+ selfBuildTarget = pkgsBuildTarget.darwin;
12+ selfHostHost = pkgsHostHost.darwin;
13+ selfTargetTarget = pkgsTargetTarget.darwin or {}; # might be missing
14+ };
715
8− impure-cmds = callPackage ../os-specific/darwin/impure-cmds { };
916in
1017
11−(impure-cmds // apple-source-releases // {
18+lib.makeScopeWithSplicing splicePackages newScope otherSplices (_: {}) (spliced: spliced.apple_sdk.frameworks) (self: let
19+ inherit (self) mkDerivation callPackage;
1220
13− callPackage = newScope (darwin.apple_sdk.frameworks // darwin);
21+ # Must use pkgs.callPackage to avoid infinite recursion.
1422
15− stdenvNoCF = stdenv.override {
16− extraBuildInputs = [];
23+ apple-source-releases = pkgs.callPackage ../os-specific/darwin/apple-source-releases { } self;
24+
25+ impure-cmds = pkgs.callPackage ../os-specific/darwin/impure-cmds { };
26+
27+ apple_sdk = pkgs.callPackage ../os-specific/darwin/apple-sdk {
28+ inherit (buildPackages.darwin) print-reexports;
29+ inherit (self) darwin-stubs;
1730 };
31+in
32+
33+impure-cmds // apple-source-releases // {
1834
19− apple_sdk = callPackage ../os-specific/darwin/apple-sdk {
20− inherit (darwin) darwin-stubs print-reexports;
35+ inherit apple_sdk;
36+
37+ stdenvNoCF = stdenv.override {
38+ extraBuildInputs = [];
2139 };
2240
2341 binutils-unwrapped = callPackage ../os-specific/darwin/binutils {
24− inherit (darwin) cctools;
2542 inherit (pkgs) binutils-unwrapped;
2643 inherit (pkgs.llvmPackages_7) llvm clang-unwrapped;
2744 };
@@ -31,17 +48,21 @@ in
3148 if stdenv.targetPlatform != stdenv.hostPlatform
3249 then pkgs.libcCross
3350 else pkgs.stdenv.cc.libc;
34− bintools = darwin.binutils-unwrapped;
51+ bintools = self.binutils-unwrapped;
52+ };
53+
54+ binutilsNoLibc = pkgs.wrapBintoolsWith {
55+ libc = null;
56+ bintools = self.binutils-unwrapped;
3557 };
3658
3759 cctools = callPackage ../os-specific/darwin/cctools/port.nix {
38− inherit (darwin) libobjc maloader libtapi;
3960 stdenv = if stdenv.isDarwin then stdenv else pkgs.libcxxStdenv;
4061 libcxxabi = pkgs.libcxxabi;
4162 };
4263
4364 # TODO: remove alias.
44− cf-private = darwin.apple_sdk.frameworks.CoreFoundation;
65+ cf-private = self.apple_sdk.frameworks.CoreFoundation;
4566
4667 DarwinTools = callPackage ../os-specific/darwin/DarwinTools { };
4768
@@ -50,15 +71,13 @@ in
5071 print-reexports = callPackage ../os-specific/darwin/apple-sdk/print-reexports { };
5172
5273 maloader = callPackage ../os-specific/darwin/maloader {
53− inherit (darwin) opencflite;
5474 };
5575
5676 insert_dylib = callPackage ../os-specific/darwin/insert_dylib { };
5777
58− iosSdkPkgs = darwin.callPackage ../os-specific/darwin/xcode/sdk-pkgs.nix {
78+ iosSdkPkgs = callPackage ../os-specific/darwin/xcode/sdk-pkgs.nix {
5979 buildIosSdk = buildPackages.darwin.iosSdkPkgs.sdk;
6080 targetIosSdkPkgs = targetPackages.darwin.iosSdkPkgs;
61− xcode = darwin.xcode;
6281 inherit (pkgs.llvmPackages) clang-unwrapped;
6382 };
6483
@@ -70,13 +89,13 @@ in
7089
7190 opencflite = callPackage ../os-specific/darwin/opencflite { };
7291
73− stubs = callPackages ../os-specific/darwin/stubs { };
92+ stubs = pkgs.callPackages ../os-specific/darwin/stubs { };
7493
75− trash = darwin.callPackage ../os-specific/darwin/trash { };
94+ trash = callPackage ../os-specific/darwin/trash { };
7695
7796 usr-include = callPackage ../os-specific/darwin/usr-include { };
7897
79− inherit (callPackages ../os-specific/darwin/xcode { })
98+ inherit (pkgs.callPackages ../os-specific/darwin/xcode { })
8099 xcode_8_1 xcode_8_2
81100 xcode_9_1 xcode_9_2 xcode_9_4 xcode_9_4_1
82101 xcode_10_2 xcode_10_2_1 xcode_10_3
@@ -85,10 +104,10 @@ in
85104
86105 CoreSymbolication = callPackage ../os-specific/darwin/CoreSymbolication { };
87106
88− CF = callPackage ../os-specific/darwin/swift-corelibs/corefoundation.nix { inherit (darwin) objc4 ICU; };
107+ CF = callPackage ../os-specific/darwin/swift-corelibs/corefoundation.nix { };
89108
90109 # 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
91− # libdispatch-broken = callPackage ../os-specific/darwin/swift-corelibs/libdispatch.nix { inherit (darwin) apple_sdk_sierra xnu; };
110+ # libdispatch-broken = callPackage ../os-specific/darwin/swift-corelibs/libdispatch.nix { };
92111
93112 darling = callPackage ../os-specific/darwin/darling/default.nix { };
94113
@@ -96,8 +115,6 @@ in
96115
97116 ios-deploy = callPackage ../os-specific/darwin/ios-deploy {};
98117
99− discrete-scroll = callPackage ../os-specific/darwin/discrete-scroll {
100− inherit (darwin.apple_sdk.frameworks) Cocoa;
101− };
118+ discrete-scroll = callPackage ../os-specific/darwin/discrete-scroll { };
102119
103120})
pkgs/top-level/static.nix+1−1
@@ -25,7 +25,7 @@ self: super: let
2525 }; in stdenv // {
2626 mkDerivation = args: stdenv.mkDerivation (args // {
2727 NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "")
28− + optionalString stdenv.cc.isGNU " -static-libgcc";
28+ + optionalString (stdenv_.cc.isGNU or false) " -static-libgcc";
2929 nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ (makeSetupHook {
3030 substitutions = {
3131 libsystem = "${stdenv.cc.libc}/lib/libSystem.B.dylib";