From e8e8643b0b0aca87db3d24b2da4bc6e9fbe3bdb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Tue, 15 Sep 2026 18:50:03 -0500 Subject: [PATCH] fetchCargoVendor: narrow the bootstrap Python override Override charset-normalizer only through requests instead of creating a separate Python package scope. This preserves the Cargo vendoring bootstrap cycle break while allowing other Python dependencies to reuse their scope. Paired evaluation samples reduce prek CPU time by about 20% and a two-hook git-hooks/prek configuration by about 12%, with unchanged derivation paths for the tested packages on Linux and aarch64-darwin. Assisted-by: OpenAI Codex (GPT-6) --- pkgs/build-support/rust/fetch-cargo-vendor.nix | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pkgs/build-support/rust/fetch-cargo-vendor.nix b/pkgs/build-support/rust/fetch-cargo-vendor.nix index 37a37f7b7bd2..94fd3815e132 100644 --- a/pkgs/build-support/rust/fetch-cargo-vendor.nix +++ b/pkgs/build-support/rust/fetch-cargo-vendor.nix @@ -11,15 +11,13 @@ }: let - python = python3.override { - self = python; - packageOverrides = final: prev: { - # The ast-serialize package, a dependency for mypy, depends on - # fetchCargoVendor and is part of the bootstrap chain for requests. - charset-normalizer = prev.charset-normalizer.override { withMypyc = false; }; + python3Packages = python3.pkgs // { + # Break the requests -> charset-normalizer -> mypy -> ast-serialize -> + # fetchCargoVendor bootstrap cycle without overriding the whole Python scope. + requests = python3.pkgs.requests.override { + charset-normalizer = python3.pkgs.charset-normalizer.override { withMypyc = false; }; }; }; - python3Packages = python.pkgs; replaceWorkspaceValues = writers.writePython3Bin "replace-workspace-values" { libraries = with python3Packages; [