From 656e3022f4caa11905bad996866bf07b848afc0b Mon Sep 17 00:00:00 2001 From: linsui Date: Sun, 26 Jun 2022 13:05:18 +0800 Subject: [PATCH] fetch-cargo-tarball: allow use index mirror --- .../rust/fetch-cargo-tarball/default.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/rust/fetch-cargo-tarball/default.nix b/pkgs/build-support/rust/fetch-cargo-tarball/default.nix index 2f1f3547dbb0..e2ee870f22a3 100644 --- a/pkgs/build-support/rust/fetch-cargo-tarball/default.nix +++ b/pkgs/build-support/rust/fetch-cargo-tarball/default.nix @@ -58,9 +58,18 @@ in stdenv.mkDerivation ({ export CARGO_HOME=$(mktemp -d cargo-home.XXX) CARGO_CONFIG=$(mktemp cargo-config.XXXX) + if [[ -n "$NIX_CRATES_INDEX" ]]; then + cat >$CARGO_HOME/config.toml < $CARGO_CONFIG + cargo vendor $name --respect-source-config | cargo-vendor-normalise > $CARGO_CONFIG # Add the Cargo.lock to allow hash invalidation cp Cargo.lock.orig $name/Cargo.lock @@ -81,7 +90,7 @@ in stdenv.mkDerivation ({ inherit (hash_) outputHashAlgo outputHash; - impureEnvVars = lib.fetchers.proxyImpureEnvVars; + impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ "NIX_CRATES_INDEX" ]; } // (builtins.removeAttrs args [ "name" "sha256" "cargoUpdateHook" "nativeBuildInputs" ]))