add ability to override lockfile from tools.nix #276
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.
I would like the ability to override the Cargo.lock file in a repository (or provide one if none exists). It looks like there is no way to do this through Cargo itself -- its source code hardcodes the path of the lockfile as the workspace root plus
/Cargo.lock
. So to override a lockfile you have to copy it in place, which is what this patch does.I'm very new to nix, so any feedback on approach is welcome.
My use case is that I'm using this crate as part of a CI infrastructure, where for a given pull request I grab every commit, dynamically produce a Cargo.nix, and build them. This is a library so it doesn't have a Cargo.lock checked in, and even if it did, there are multiple lockfiles I'd like to test with (a "minimum supported versions" one and a "latest versons of all deps" one), so the checked-in version wouldn't be sufficient.
My current non-nix solution involves doing a shallow checkout of every commit and doing a fresh build, which is roughly what
buildRustPackages
would do if I were to naively port my setup into nix. But this is incredibly wasteful, since it rebuilds my entire dep tree on every commit, even though (for normal PRs) the dependency tree doesn't change at all.