Merge pull request #215906 from figsoda/update

This commit is contained in:
figsoda
2023-03-06 14:37:03 -05:00
committed by GitHub
2 changed files with 3 additions and 38 deletions
@@ -8,6 +8,7 @@
, libiconv
, useMimalloc ? false
, doCheck ? true
, nix-update-script
}:
rustPlatform.buildRustPackage rec {
@@ -29,7 +30,7 @@ rustPlatform.buildRustPackage rec {
# Code format check requires more dependencies but don't really matter for packaging.
# So just ignore it.
checkFlags = ["--skip=tidy::check_code_formatting"];
checkFlags = [ "--skip=tidy::check_code_formatting" ];
nativeBuildInputs = lib.optional useMimalloc cmake;
@@ -57,7 +58,7 @@ rustPlatform.buildRustPackage rec {
'';
passthru = {
updateScript = ./update.sh;
updateScript = nix-update-script { };
# FIXME: Pass overrided `rust-analyzer` once `buildRustPackage` also implements #119942
tests.neovim-lsp = callPackage ./test-neovim-lsp.nix { };
};
@@ -1,36 +0,0 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq nix-prefetch libarchive
# shellcheck shell=bash
set -euo pipefail
cd "$(dirname "$0")"
owner=rust-lang
repo=rust-analyzer
nixpkgs=../../../../..
# Update lsp
ver=$(
curl -s "https://api.github.com/repos/$owner/$repo/releases" |
jq 'map(select(.prerelease | not)) | .[0].tag_name' --raw-output
)
old_ver=$(sed -nE 's/.*\bversion = "(.*)".*/\1/p' ./default.nix)
if grep -q 'cargoSha256 = ""' ./default.nix; then
old_ver='broken'
fi
if [[ "$ver" == "$old_ver" ]]; then
echo "Up to date: $ver"
exit
fi
echo "$old_ver -> $ver"
sha256=$(nix-prefetch -f "$nixpkgs" rust-analyzer-unwrapped.src --rev "$ver")
# Clear cargoSha256 to avoid inconsistency.
sed -e "s#version = \".*\"#version = \"$ver\"#" \
-e "/fetchFromGitHub/,/}/ s#sha256 = \".*\"#sha256 = \"$sha256\"#" \
-e "s#cargoSha256 = \".*\"#cargoSha256 = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"#" \
--in-place ./default.nix
echo "Prebuilding for cargoSha256"
cargo_sha256=$(nix-prefetch "{ sha256 }: (import $nixpkgs {}).rust-analyzer-unwrapped.cargoDeps.overrideAttrs (_: { outputHash = sha256; })")
sed "s#cargoSha256 = \".*\"#cargoSha256 = \"$cargo_sha256\"#" \
--in-place ./default.nix