From f07977cfd2645273d6626f276bedf30755c053af Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 28 Jan 2025 10:37:52 +0100 Subject: [PATCH] rustPlatform.fetchCargoVendor: add allowGitDependencies This will make it possible to use fetchCargoVendor for packages that are in the dependency graph of nix-prefetch-git, by having them opt out of having nix-prefetch-git involved in fetching their dependencies. --- pkgs/build-support/rust/fetch-cargo-vendor.nix | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/rust/fetch-cargo-vendor.nix b/pkgs/build-support/rust/fetch-cargo-vendor.nix index 899c799c5fcc..e346ab659af6 100644 --- a/pkgs/build-support/rust/fetch-cargo-vendor.nix +++ b/pkgs/build-support/rust/fetch-cargo-vendor.nix @@ -35,6 +35,9 @@ in name ? if args ? pname && args ? version then "${args.pname}-${args.version}" else "cargo-deps", hash ? (throw "fetchCargoVendor requires a `hash` value to be set for ${name}"), nativeBuildInputs ? [ ], + # This is mostly for breaking infinite recursion where dependencies + # of nix-prefetch-git use fetchCargoVendor. + allowGitDependencies ? true, ... }@args: @@ -53,11 +56,15 @@ let { name = "${name}-vendor-staging"; - nativeBuildInputs = [ - fetchCargoVendorUtil - nix-prefetch-git - cacert - ] ++ nativeBuildInputs; + nativeBuildInputs = + [ + fetchCargoVendorUtil + cacert + ] + ++ lib.optionals allowGitDependencies [ + nix-prefetch-git + ] + ++ nativeBuildInputs; buildPhase = '' runHook preBuild