1 #!/usr/bin/env nix-shell
2 #! nix-shell -p nix jq curl cargo rsync
11 echo "Getting latest version from crates.io API" >&2
14 -H "Accept: application/json"
15 -H "User-Agent: $crate update script (https://github.com/nixos/nixpkgs/)"
18 version
="$(curl "${curlOpts[@]}" "https
://crates.io
/api
/v
1/crates
/$crate" \
19 | jq -r .crate.max_stable_version)"
21 echo "Prefetching latest tarball from crates.io" >&2
23 url
="https://crates.io/api/v1/crates/$crate/$version/download"
24 prefetch
="$(nix-prefetch-url --print-path --type sha256 --unpack "$url")"
29 "version": "$version",
30 "sha256": "$(printf '%s' "$prefetch" | head -n1)"
34 echo "Generating updated Cargo.lock" >&2
39 echo "Removing $tmp" >&2
45 rsync
-a --chmod=ugo
=rwX
"$(printf '%s' "$prefetch" | tail -n1)/" "$tmp"
51 cp "$tmp/Cargo.lock" .
/Cargo.lock