diff --git a/pkgs/by-name/ca/cargo-c/package.nix b/pkgs/by-name/ca/cargo-c/package.nix index 3624b19e5388..153c578518b2 100644 --- a/pkgs/by-name/ca/cargo-c/package.nix +++ b/pkgs/by-name/ca/cargo-c/package.nix @@ -10,14 +10,17 @@ rav1e, }: +let + # this version may need to be updated along with package version + cargoVersion = "0.80.0"; +in rustPlatform.buildRustPackage rec { pname = "cargo-c"; version = "0.10.2"; src = fetchCrate { inherit pname; - # this version may need to be updated along with package version - version = "${version}+cargo-0.80.0"; + version = "${version}+cargo-${cargoVersion}"; hash = "sha256-ltxd4n3oo8ZF/G/zmR4FSVtNOkxwCjDv6PdxkmWxZ+8="; }; @@ -47,8 +50,11 @@ rustPlatform.buildRustPackage rec { runHook postInstallCheck ''; - passthru.tests = { - inherit rav1e; + passthru = { + tests = { + inherit rav1e; + }; + updateScript.command = [ ./update.sh ]; }; meta = { diff --git a/pkgs/by-name/ca/cargo-c/update.sh b/pkgs/by-name/ca/cargo-c/update.sh new file mode 100755 index 000000000000..fe1137043aea --- /dev/null +++ b/pkgs/by-name/ca/cargo-c/update.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p bash curl coreutils nix-update jq + +set -ex + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" + +latestVersion=`curl https://crates.io/api/v1/crates/cargo-c/versions | jq '.versions[0].num | split("+cargo-")'` +crateVersion=`jq -r '.[0]' <<< $latestVersion` +cargoVersion=`jq -r '.[1]' <<< $latestVersion` + +sed -E -i "s/(cargoVersion = ).*;/\1\"$cargoVersion\";/" $SCRIPT_DIR/package.nix + +nix-update cargo-c --version="$crateVersion"