
update-rust-derivation
by shinzui
My dotfiles in NIX
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
-
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:
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> -
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:
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.
-
Update cargoHash: Replace
lib.fakeHashwith the actual cargoHash from the build output. -
Verify the build:
nix 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)
スコア
総合スコア
リポジトリの品質指標に基づく評価
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
レビュー
レビュー機能は近日公開予定です