Update Rust Derivation
Update the Rust derivation: $ARGUMENTS
Steps
- •
Read the derivation: Read the derivation file to understand its current structure, version, and hash fields.
- •
Update the version: Change the
versionattribute to the new version. - •
Get the source hash:
bashnix-prefetch-url --unpack "https://github.com/<owner>/<repo>/archive/refs/tags/v<version>.tar.gz"
Then convert to SRI format:
bashnix hash to-sri --type sha256 <hash>
- •
Update the source hash: Replace the
hashattribute infetchFromGitHubwith the new SRI hash. - •
Set cargoHash to placeholder: Temporarily set
cargoHash = lib.fakeHash;to trigger nix to compute the correct hash. - •
Build to get cargoHash:
bashnix build --impure --expr 'let pkgs = import <nixpkgs> {}; in pkgs.callPackage ./<path-to-derivation> {}' 2>&1 | grep -A2 "got:"Extract the correct cargoHash from the error output.
- •
Update cargoHash: Replace
lib.fakeHashwith the actual cargoHash from the build output. - •
Verify the build:
bashnix build --impure --expr 'let pkgs = import <nixpkgs> {}; in pkgs.callPackage ./<path-to-derivation> {}'Ensure the build completes successfully.
- •
Summary: Report the version update (old -> new) and remind to run
darwin-rebuild switch --flake .to apply changes.
Notes
- •The derivation must use
rustPlatform.buildRustPackagewithcargoHash - •If using
cargoLockinstead ofcargoHash, the process differs (fetch Cargo.lock from repo) - •Some packages may have additional attributes that need updating (e.g.,
patches,buildInputs)