about summary refs log tree commit diff
path: root/pkgs/stdenv
diff options
context:
space:
mode:
authorRandy Eckenrode <randy@largeandhighquality.com>2024-03-17 16:44:56 -0400
committerRandy Eckenrode <randy@largeandhighquality.com>2024-03-17 16:48:35 -0400
commit07451425e7a6c177444381d1f51074cbeaaf11bc (patch)
treee5ccbc0e7c35a4a71f33d6a6ae7f934aea459256 /pkgs/stdenv
parent42b1ed91caadd880f72f6d33b0a5ee58f161fd35 (diff)
darwin.stdenv: drop curl from the bootstrap
The Darwin bootstrap currently requires curl, but it is not strictly
required. The bootstrap requires it for two things:

* Fetchers; and
* As a transitive dependency of llvm-manpages (via Sphinx).

For the fetchers, the bootstrap curl can be used. For hatch-vcs, the
dependency, its tests can be disabled. Doing this allows curl to be
dropped from the Darwin stdenv bootstrap.
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/darwin/default.nix66
1 files changed, 33 insertions, 33 deletions
diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix
index e2ebe4d6bbb5d..b1094630dd465 100644
--- a/pkgs/stdenv/darwin/default.nix
+++ b/pkgs/stdenv/darwin/default.nix
@@ -158,8 +158,16 @@ let
         __stdenvImpureHostDeps = commonImpureHostDeps;
         __extraImpureHostDeps = commonImpureHostDeps;
 
+        # Using the bootstrap tools curl for fetchers allows the stdenv bootstrap to avoid
+        # having a dependency on curl, allowing curl to be updated without triggering a
+        # new stdenv bootstrap on Darwin.
         overrides = self: super: (overrides self super) // {
           fetchurl = thisStdenv.fetchurlBoot;
+          fetchpatch = super.fetchpatch.override { inherit (self) fetchurl; };
+          fetchgit = super.fetchgit.override {
+            git = super.git.override { curl = bootstrapTools; };
+          };
+          fetchzip = super.fetchzip.override { inherit (self) fetchurl; };
         };
       };
 
@@ -415,8 +423,6 @@ in
         buildInputs = old.buildInputs ++ [ self.darwin.CF ];
       });
 
-      curl = super.curlMinimal;
-
       # Disable tests because they use dejagnu, which fails to run.
       libffi = super.libffi.override { doCheck = false; };
 
@@ -489,8 +495,9 @@ in
     '';
   })
 
-  # Build sysctl and Python for use by LLVM’s check phase. These must be built in their
-  # own stage, or an infinite recursion results on x86_64-darwin when using the source-based SDK.
+  # Build cctools, Python, and sysctl for use by LLVM’s check phase. They must be built in
+  # their stage to prevent infinite recursions and to make sure the stdenv used to build
+  # LLVM has the newly built cctools instead of the one from the bootstrap tools.
   (prevStage:
     # previous stage1 stdenv:
     assert lib.all isFromBootstrapFiles (with prevStage; [ coreutils gnugrep ]);
@@ -1027,40 +1034,11 @@ in
         # LLVM dependencies - don’t rebuild them.
         libffi libiconv libxml2 ncurses zlib;
 
-      # These overrides are required to break an infinite recursion. curl depends on Darwin
-      # frameworks, but those frameworks require these dependencies to build, which
-      # depend on curl indirectly.
-      cpio = super.cpio.override {
-        inherit (prevStage) fetchurl;
-      };
-
-      libyaml = super.libyaml.override {
-        inherit (prevStage) fetchFromGitHub;
-      };
-
-      pbzx = super.pbzx.override {
-        inherit (prevStage) fetchFromGitHub;
-      };
-
-      python3Minimal = super.python3Minimal.override {
-        inherit (prevStage) fetchurl;
-      };
-
-      xar = super.xar.override {
-        inherit (prevStage) fetchurl;
-      };
-
       darwin = super.darwin.overrideScope (selfDarwin: superDarwin: {
         inherit (prevStage.darwin) dyld CF Libsystem darwin-stubs
           # CF dependencies - don’t rebuild them.
           libobjc objc4;
 
-        # rewrite-tbd is also needed to build Darwin frameworks, so it’s built using the
-        # previous stage’s fetchFromGitHub to avoid an infinite recursion (same as above).
-        rewrite-tbd = superDarwin.rewrite-tbd.override {
-          inherit (prevStage) fetchFromGitHub;
-        };
-
         signingUtils = superDarwin.signingUtils.override {
           inherit (selfDarwin) sigtool;
         };
@@ -1075,6 +1053,28 @@ in
           bintools = selfDarwin.binutils-unwrapped;
           libc = selfDarwin.Libsystem;
         };
+
+        # cctools needs to build the LLVM man pages, which requires sphinx. Sphinx
+        # has hatch-vcs as a transitive dependency, which pulls in git (and curl).
+        # Disabling the tests for hatch-vcs allows the stdenv bootstrap to avoid having
+        # any dependency on curl other than the one provided in the bootstrap tools.
+        cctools-llvm = superDarwin.cctools-llvm.override (old: {
+          llvmPackages =
+            let
+              tools = old.llvmPackages.tools.extend (_: superTools: {
+                llvm-manpages = superTools.llvm-manpages.override {
+                  python3Packages = prevStage.python3Packages.overrideScope (_: superPython: {
+                    hatch-vcs = (superPython.hatch-vcs.override {
+                      git = null;
+                      pytestCheckHook = null;
+                    });
+                  });
+                };
+              });
+              inherit (old.llvmPackages) libraries release_version;
+            in
+            { inherit tools libraries release_version; } // tools // libraries;
+        });
       });
 
       llvmPackages = super.llvmPackages // (