From 4928668e21d1efb681434c1caa95c449db9dd599 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Mon, 24 Mar 2025 07:52:18 -0400 Subject: [PATCH] stdenvNoCC: drop `extraBuildInputs` on Darwin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Darwin includes its SDK in `extraBuildInputs`, which isn’t needed in `stdenvNoCC` because it depends on a compiler. Including it greatly increases the size of the `stdenvNoCC` closure (by ~1 GiB). This wasn’t an issue in the past when darwin included CoreFoundation because CoreFoundation on its own is very small. Now that it includes the whole SDK and links some bintools, it pulls in 300~400 MiB for the SDK plus another ~445 MiB for LLVM. Fixes #371465 --- pkgs/top-level/stage.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/top-level/stage.nix b/pkgs/top-level/stage.nix index 5f9d86b1e125..0df1780acf5c 100644 --- a/pkgs/top-level/stage.nix +++ b/pkgs/top-level/stage.nix @@ -51,7 +51,15 @@ in , # `stdenv` without a C compiler. Passing in this helps avoid infinite # recursions, and may eventually replace passing in the full stdenv. - stdenvNoCC ? stdenv.override { cc = null; hasCC = false; } + stdenvNoCC ? ( + stdenv.override { + cc = null; + hasCC = false; + } + # Darwin doesn’t need an SDK in `stdenvNoCC`. Dropping it shrinks the closure + # size down from ~1 GiB to ~83 MiB, which is a considerable reduction. + // lib.optionalAttrs stdenv.hostPlatform.isDarwin { extraBuildInputs = [ ]; } + ) , # This is used because stdenv replacement and the stdenvCross do benefit from # the overridden configuration provided by the user, as opposed to the normal