Merge pull request #178964 from linsui/cargo
fetch-cargo-tarball: allow use index mirror
This commit is contained in:
commit
1066f0ef92
4 changed files with 20 additions and 7 deletions
|
@ -52,7 +52,8 @@
|
||||||
, buildAndTestSubdir ? null
|
, buildAndTestSubdir ? null
|
||||||
, ... } @ args:
|
, ... } @ args:
|
||||||
|
|
||||||
assert cargoVendorDir == null && cargoLock == null -> !(args ? cargoSha256) && !(args ? cargoHash)
|
assert cargoVendorDir == null && cargoLock == null
|
||||||
|
-> !(args ? cargoSha256 && args.cargoSha256 != null) && !(args ? cargoHash && args.cargoHash != null)
|
||||||
-> throw "cargoSha256, cargoHash, cargoVendorDir, or cargoLock must be set";
|
-> throw "cargoSha256, cargoHash, cargoVendorDir, or cargoLock must be set";
|
||||||
assert buildType == "release" || buildType == "debug";
|
assert buildType == "release" || buildType == "debug";
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,9 @@ def quote(s: str) -> str:
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
data = toml.load(sys.stdin)
|
data = toml.load(sys.stdin)
|
||||||
|
|
||||||
assert list(data.keys()) == ["source"]
|
# There is no dependency to vendor in this project.
|
||||||
|
if not list(data.keys()) == ["source"]:
|
||||||
|
return
|
||||||
|
|
||||||
# this value is non deterministic
|
# this value is non deterministic
|
||||||
data["source"]["vendored-sources"]["directory"] = "@vendor@"
|
data["source"]["vendored-sources"]["directory"] = "@vendor@"
|
||||||
|
|
|
@ -58,10 +58,21 @@ in stdenv.mkDerivation ({
|
||||||
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
||||||
CARGO_CONFIG=$(mktemp cargo-config.XXXX)
|
CARGO_CONFIG=$(mktemp cargo-config.XXXX)
|
||||||
|
|
||||||
|
if [[ -n "$NIX_CRATES_INDEX" ]]; then
|
||||||
|
cat >$CARGO_HOME/config.toml <<EOF
|
||||||
|
[source.crates-io]
|
||||||
|
replace-with = 'mirror'
|
||||||
|
[source.mirror]
|
||||||
|
registry = "$NIX_CRATES_INDEX"
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
${cargoUpdateHook}
|
${cargoUpdateHook}
|
||||||
|
|
||||||
cargo vendor $name | cargo-vendor-normalise > $CARGO_CONFIG
|
cargo vendor $name --respect-source-config | cargo-vendor-normalise > $CARGO_CONFIG
|
||||||
|
|
||||||
|
# Create an empty vendor directory when there is no dependency to vendor
|
||||||
|
mkdir -p $name
|
||||||
# Add the Cargo.lock to allow hash invalidation
|
# Add the Cargo.lock to allow hash invalidation
|
||||||
cp Cargo.lock.orig $name/Cargo.lock
|
cp Cargo.lock.orig $name/Cargo.lock
|
||||||
|
|
||||||
|
@ -81,7 +92,7 @@ in stdenv.mkDerivation ({
|
||||||
|
|
||||||
inherit (hash_) outputHashAlgo outputHash;
|
inherit (hash_) outputHashAlgo outputHash;
|
||||||
|
|
||||||
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
|
impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ "NIX_CRATES_INDEX" ];
|
||||||
} // (builtins.removeAttrs args [
|
} // (builtins.removeAttrs args [
|
||||||
"name" "sha256" "cargoUpdateHook" "nativeBuildInputs"
|
"name" "sha256" "cargoUpdateHook" "nativeBuildInputs"
|
||||||
]))
|
]))
|
||||||
|
|
|
@ -11,8 +11,7 @@ rustPlatform.buildRustPackage rec {
|
||||||
sha256 = "sha256-NzFKNCCPWBj/fhaEJF34nyeyvLMeQwIcQgTlYc6mgYo=";
|
sha256 = "sha256-NzFKNCCPWBj/fhaEJF34nyeyvLMeQwIcQgTlYc6mgYo=";
|
||||||
};
|
};
|
||||||
|
|
||||||
# There is no dependency to vendor in this project.
|
cargoHash = "sha256-Dc+SuLwbLFcNSr9RiNSc7dgisBOvOUEIDR8dFAkC/O0=";
|
||||||
cargoLock.lockFile = ./Cargo.lock;
|
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "ELF visualizer, generates HTML files from ELF binaries.";
|
description = "ELF visualizer, generates HTML files from ELF binaries.";
|
||||||
|
|
Loading…
Reference in a new issue