2020-04-24 23:36:52 +00:00
|
|
|
#!/usr/bin/env nix-shell
|
2021-08-10 14:31:46 +00:00
|
|
|
#!nix-shell -i bash -p curl jq nix-prefetch libarchive
|
2022-03-30 09:31:56 +00:00
|
|
|
# shellcheck shell=bash
|
2020-04-24 23:36:52 +00:00
|
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
owner=rust-analyzer
|
|
|
|
repo=rust-analyzer
|
|
|
|
nixpkgs=../../../../..
|
|
|
|
|
|
|
|
# Update lsp
|
|
|
|
|
2021-04-13 19:44:15 +00:00
|
|
|
ver=$(
|
2020-04-24 23:36:52 +00:00
|
|
|
curl -s "https://api.github.com/repos/$owner/$repo/releases" |
|
|
|
|
jq 'map(select(.prerelease | not)) | .[0].tag_name' --raw-output
|
|
|
|
)
|
2021-04-13 19:44:15 +00:00
|
|
|
old_ver=$(sed -nE 's/.*\bversion = "(.*)".*/\1/p' ./default.nix)
|
2020-04-24 23:36:52 +00:00
|
|
|
if grep -q 'cargoSha256 = ""' ./default.nix; then
|
2021-04-13 19:44:15 +00:00
|
|
|
old_ver='broken'
|
2020-04-24 23:36:52 +00:00
|
|
|
fi
|
2021-04-13 19:44:15 +00:00
|
|
|
if [[ "$ver" == "$old_ver" ]]; then
|
|
|
|
echo "Up to date: $ver"
|
2020-04-24 23:36:52 +00:00
|
|
|
exit
|
|
|
|
fi
|
2021-04-13 19:44:15 +00:00
|
|
|
echo "$old_ver -> $ver"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-13 19:44:15 +00:00
|
|
|
sha256=$(nix-prefetch -f "$nixpkgs" rust-analyzer-unwrapped.src --rev "$ver")
|
2020-04-24 23:36:52 +00:00
|
|
|
# Clear cargoSha256 to avoid inconsistency.
|
2021-04-13 19:44:15 +00:00
|
|
|
sed -e "s#version = \".*\"#version = \"$ver\"#" \
|
2021-04-12 18:23:04 +00:00
|
|
|
-e "/fetchFromGitHub/,/}/ s#sha256 = \".*\"#sha256 = \"$sha256\"#" \
|
2021-01-09 10:05:03 +00:00
|
|
|
-e "s#cargoSha256 = \".*\"#cargoSha256 = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"#" \
|
2020-04-24 23:36:52 +00:00
|
|
|
--in-place ./default.nix
|
|
|
|
|
|
|
|
echo "Prebuilding for cargoSha256"
|
|
|
|
cargo_sha256=$(nix-prefetch "{ sha256 }: (import $nixpkgs {}).rust-analyzer-unwrapped.cargoDeps.overrideAttrs (_: { outputHash = sha256; })")
|
2020-11-09 15:59:12 +00:00
|
|
|
sed "s#cargoSha256 = \".*\"#cargoSha256 = \"$cargo_sha256\"#" \
|
2020-04-24 23:36:52 +00:00
|
|
|
--in-place ./default.nix
|