From 953d54f69117f4c79269e11f69ebafee5507d972 Mon Sep 17 00:00:00 2001 From: figsoda Date: Sat, 11 Feb 2023 21:05:49 -0500 Subject: [PATCH] rust-analyzer: use nix-update-script --- .../tools/rust/rust-analyzer/default.nix | 5 +-- .../tools/rust/rust-analyzer/update.sh | 36 ------------------- 2 files changed, 3 insertions(+), 38 deletions(-) delete mode 100755 pkgs/development/tools/rust/rust-analyzer/update.sh diff --git a/pkgs/development/tools/rust/rust-analyzer/default.nix b/pkgs/development/tools/rust/rust-analyzer/default.nix index f00c79b3e76c..5f265c43613c 100644 --- a/pkgs/development/tools/rust/rust-analyzer/default.nix +++ b/pkgs/development/tools/rust/rust-analyzer/default.nix @@ -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 { }; }; diff --git a/pkgs/development/tools/rust/rust-analyzer/update.sh b/pkgs/development/tools/rust/rust-analyzer/update.sh deleted file mode 100755 index 36c3fd3941b9..000000000000 --- a/pkgs/development/tools/rust/rust-analyzer/update.sh +++ /dev/null @@ -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