update-source-version: update cargo hash if exists #392827
Open
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.
Let
gitUpdater
work withrustPlatform.buildRustPackage
; if$attr.cargoHash
exists, update it.Current behavior
If we do something like
we would get error like
nixpkgs/pkgs/build-support/rust/hooks/cargo-setup-hook.sh
Lines 68 to 76 in 97dc21f
because
cargoHash
was never updated.Why now?
Since #349360 is here, rust packages no longer bundle their
flake.lock
inside nixpkgs and now theircargoDeps
only depend oncargoHash
, making updates much easier to automate.Difference from original hash replacing logic
I copied most of the hash updating behavior from the original script, but 1) default to replacing a fake sha256 hash as I see no one using sha512 in
cargoHash
; and 2) skipped non-SRI-style hash handling sincecargoSha256
is deprecated:nixpkgs/doc/languages-frameworks/rust.section.md
Lines 52 to 59 in fb65bbf
Testing
I only tested this against
firecracker
so far. Appreciate if other maintainers can test on their rust packages also. 🙏Open to suggestions, whether this is something needed or not; or if this should be implemented somewhere else and not polluting the
update-source-version
.Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.