Merge pull request #130462 from rski/importCargoLock

rustPlatform.importCargoLock: add an assert for old Cargo.locks
This commit is contained in:
Daniël de Kok 2021-07-18 18:57:48 +02:00 committed by GitHub
commit b2fac1cfe0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,11 +63,19 @@ let
# We can't use the existing fetchCrate function, since it uses a
# recursive hash of the unpacked crate.
fetchCrate = pkg: fetchurl {
name = "crate-${pkg.name}-${pkg.version}.tar.gz";
url = "https://crates.io/api/v1/crates/${pkg.name}/${pkg.version}/download";
sha256 = pkg.checksum;
};
fetchCrate = pkg:
assert lib.assertMsg (pkg ? checksum) ''
Package ${pkg.name} does not have a checksum.
Please note that the Cargo.lock format where checksums used to be listed
under [metadata] is not supported.
If that is the case, running `cargo update` with a recent toolchain will
automatically update the format along with the crate's depenendencies.
'';
fetchurl {
name = "crate-${pkg.name}-${pkg.version}.tar.gz";
url = "https://crates.io/api/v1/crates/${pkg.name}/${pkg.version}/download";
sha256 = pkg.checksum;
};
# Fetch and unpack a crate.
mkCrate = pkg: