@@ -22,11 +22,17 @@ in
2222, srcs ? []
2323, patches ? []
2424, sourceRoot
25−, sha256
25+, hash ? ""
26+, sha256 ? ""
2627, cargoUpdateHook ? ""
2728, ...
2829} @ args:
29−stdenv.mkDerivation ({
30+
31+let hash_ =
32+ if hash != "" then { outputHashAlgo = null; outputHash = hash; }
33+ else if sha256 != "" then { outputHashAlgo = "sha256"; outputHash = sha256; }
34+ else throw "fetchCargoTarball requires a hash for ${name}";
35+in stdenv.mkDerivation ({
3036 name = "${name}-vendor.tar.gz";
3137 nativeBuildInputs = [ cacert git cargo-vendor-normalise cargo ];
3238
@@ -40,7 +46,7 @@ stdenv.mkDerivation ({
4046 echo
4147 echo "ERROR: The Cargo.lock file doesn't exist"
4248 echo
43− echo "Cargo.lock is needed to make sure that cargoSha256 doesn't change"
49+ echo "Cargo.lock is needed to make sure that cargoHash/cargoSha256 doesn't change"
4450 echo "when the registry is updated."
4551 echo
4652
@@ -72,8 +78,7 @@ stdenv.mkDerivation ({
7278 -czf $out $name
7379 '';
7480
75− outputHashAlgo = "sha256";
76− outputHash = sha256;
81+ inherit (hash_) outputHashAlgo outputHash;
7782
7883 impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars;
7984} // (builtins.removeAttrs args [