-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buildRustPackage: add verifyCargoDeps option #67387
Conversation
This PR needs a bit of testing. For now I am just looking for review on the idea. |
Upstream seems to want to change the Cargo.lock format, so there could be spurious hash invalidations. |
Good to know. I don't think this would be a major issue since the Cargo.lock is provided by upstream. So when updating the src hash, the cargoSha256 might also change, which seems reasonable to me. This feature is mainly meant to be used outside of nixpkgs since comparing the lockfiles requires to use IFD. |
About IFD, this assert could be checked in the builder of the derivation, right ? |
Right, good thinking! And since the argument is passed to the main builder it will work nicely. I will add that shortly. |
0a51b5b
to
7a16323
Compare
This is a rather nice idea, if the format of the lockfile is stable enough (notably across cargo upgrades). |
Yeah it works quite nicely. Here is how it looks like when the cargoSha256 is out of date:
I am almost tempted to migrate all the packages to use this feature. Having to update the cargoSha256 a bit more frequently is probably preferable than having them out of sync because the package maintainer forgot to update it. |
|
7a16323
to
9abc87d
Compare
Ok this PR is ready |
Can you document the new flag in |
There should be also a warning that this can potentially break the build when in cargo changes the lockfile format in future. For many users this won't be a big problem though. In nixpkgs we can coordinate such breakages when updating rustc. It will be only annoying when backporting updates... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me apart from missing documentation.
One issue with cargoSha256 is that it's hard to detect when it needs to be updated or not. It's possible to upgrade a package and forget to update cargoSha256 and run with old versions of the program or libraries. This commit introduces `verifyCargoDeps` which, when enabled, will check that the Cargo.lock is not out of date in the cargoDeps by comparing it with the package source.
9abc87d
to
ee00d08
Compare
thanks for calling me out on the docs. Added those and did a quick rebase. |
When enabled, it allows to check whenever the cargoSha256 needs updating
or not. This technique depends on IFD and is not allowed inside of
nixpkgs but it's handy to have available. Eg:
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Notify maintainers
cc @