From 9e00f0c852f4ca21057fc82c1c139eb97a6313a4 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Thu, 26 Mar 2026 18:58:27 +1300 Subject: [PATCH] rustPlatform.fetchCargoVendor: Don't recompute internal data Calling nix-prefetch-git.override on every call to fetchCargoVendor is bad for performance. --- .../build-support/rust/fetch-cargo-vendor.nix | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/pkgs/build-support/rust/fetch-cargo-vendor.nix b/pkgs/build-support/rust/fetch-cargo-vendor.nix index a02bbd89c7fc..2802bf9e73f1 100644 --- a/pkgs/build-support/rust/fetch-cargo-vendor.nix +++ b/pkgs/build-support/rust/fetch-cargo-vendor.nix @@ -22,6 +22,21 @@ let ]; } (builtins.readFile ./replace-workspace-values.py); + nix-prefetch-git' = nix-prefetch-git.override { + git = gitMinimal; + # break loop of nix-prefetch-git -> git-lfs -> asciidoctor -> ruby (yjit) -> fetchCargoVendor -> nix-prefetch-git + # Cargo does not currently handle git-lfs: https://github.com/rust-lang/cargo/issues/9692 + git-lfs = null; + }; + + removedArgs = [ + "name" + "pname" + "version" + "nativeBuildInputs" + "hash" + ]; + mkFetchCargoVendorUtil = name: src: writers.writePython3Bin name { @@ -57,14 +72,6 @@ in # TODO: add asserts about pname version and name let - removedArgs = [ - "name" - "pname" - "version" - "nativeBuildInputs" - "hash" - ]; - vendorStaging = stdenvNoCC.mkDerivation ( { name = "${name}-vendor-staging"; @@ -74,12 +81,7 @@ let nativeBuildInputs = [ fetchCargoVendorUtilV2 cacert - (nix-prefetch-git.override { - git = gitMinimal; - # break loop of nix-prefetch-git -> git-lfs -> asciidoctor -> ruby (yjit) -> fetchCargoVendor -> nix-prefetch-git - # Cargo does not currently handle git-lfs: https://github.com/rust-lang/cargo/issues/9692 - git-lfs = null; - }) + nix-prefetch-git' ] ++ nativeBuildInputs; @@ -108,7 +110,6 @@ let // removeAttrs args removedArgs ); in - runCommand "${name}-vendor" { inherit vendorStaging;