Back to list
shinzui

update-rust-derivation

by shinzui

My dotfiles in NIX

6🍴 0📅 Jan 24, 2026

SKILL.md


name: update-rust-derivation description: Update a Rust derivation to a new version with correct hashes. Use when the user wants to update a Rust package in their nix derivations.

Update Rust Derivation

Update the Rust derivation: $ARGUMENTS

Steps

  1. Read the derivation: Read the derivation file to understand its current structure, version, and hash fields.

  2. Update the version: Change the version attribute to the new version.

  3. Get the source hash:

    nix-prefetch-url --unpack "https://github.com/<owner>/<repo>/archive/refs/tags/v<version>.tar.gz"
    

    Then convert to SRI format:

    nix hash to-sri --type sha256 <hash>
    
  4. Update the source hash: Replace the hash attribute in fetchFromGitHub with the new SRI hash.

  5. Set cargoHash to placeholder: Temporarily set cargoHash = lib.fakeHash; to trigger nix to compute the correct hash.

  6. Build to get cargoHash:

    nix 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.

  7. Update cargoHash: Replace lib.fakeHash with the actual cargoHash from the build output.

  8. Verify the build:

    nix build --impure --expr 'let pkgs = import <nixpkgs> {}; in pkgs.callPackage ./<path-to-derivation> {}'
    

    Ensure the build completes successfully.

  9. Summary: Report the version update (old -> new) and remind to run darwin-rebuild switch --flake . to apply changes.

Notes

  • The derivation must use rustPlatform.buildRustPackage with cargoHash
  • If using cargoLock instead of cargoHash, the process differs (fetch Cargo.lock from repo)
  • Some packages may have additional attributes that need updating (e.g., patches, buildInputs)

Score

Total Score

50/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon