fix parsing checksums from v1 manifests with latest cargo #381
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Crate2nix identifies packages using package ID strings reported by the
cargo metadata
subcommand. Cargo describes these strings as internal identifiers subject to change. And in fact the string format did change sometime between cargo 1.76 and cargo 1.78.In cargo 1.76 package ID strings look like this:
In later cargo versions the format changed to look like this:
The change is fine as long as package IDs are used as opaque identifiers in memory. Unfortunately one use of package IDs is to look up checksums in the legacy v1
Cargo.lock
manifest format. That format stores checksums in a map at the end of the file that looks like this:Being a legacy format the keys in these checksum maps will always use the old package ID format. The problem becomes quickly apparent because nix-test-runner - which is used in the crate2nix test suite - happens to use a v1 manifest. That leads to tests and the devShell breaking when attempting to update crate2nix flake inputs.
Currently crate2nix assumes that package IDs read from
cargo metadata
output can be used as lookup keys in the v1 checksum map. But when a recent version of cargo is installed that assumption is broken.This PR fixes the problem by constructing checksum lookup keys explicitly. This should make checksum lookups work regardless of which cargo version is installed.