Commit graph

2 commits

Author SHA1 Message Date
Romanos Skiadas 23dd37dd5e rustPlatform.importCargoLock: add an assert for old Cargo.locks
near the end of 2019, the default Cargo.lock format was changed to
[[package]]
checksum = ...

This is what importCargoLock assumes. If the crate had not been `cargo
update`'d with a more recent toolchain than the one with the new
format as default, importCargoLock would fail when trying to access
pkg.checksum.

I ran into such a case (shamefully, in my own crate) and it took me a
while to figure out what was going on, so here is an assert with a
more user friendly message and a hint.
2021-07-18 18:19:50 +03:00
Daniël de Kok 2f46d77e28 rustPlatform.importCargoLock: init
This function can be used to create an output path that is a cargo
vendor directory. In contrast to e.g. fetchCargoTarball all the
dependent crates are fetched using fixed-output derivations. The
hashes for the fixed-output derivations are gathered from the
Cargo.lock file.

Usage is very simple, e.g.:

importCargoLock {
  lockFile = ./Cargo.lock;
}

would use the lockfile from the current directory.

The implementation of this function is based on Eelco Dolstra's
import-cargo:

https://github.com/edolstra/import-cargo/blob/master/flake.nix

Compared to upstream:

- We use fetchgit in place of builtins.fetchGit.
- Sync to current cargo vendoring.
2021-05-28 08:01:25 +02:00