vscode-extensions.matklad.rust-analyzer: split from rust-analyzer

Also remove oxalica from maintainers.
This commit is contained in:
oxalica 2021-12-15 05:52:46 +08:00
parent dcf4fb5133
commit d8c8e3f6d1
No known key found for this signature in database
GPG key ID: CED392DE0C483D00
2 changed files with 16 additions and 49 deletions

View file

@ -28,50 +28,8 @@ sed -e "s#version = \".*\"#version = \"$ver\"#" \
-e "/fetchFromGitHub/,/}/ s#sha256 = \".*\"#sha256 = \"$sha256\"#" \ -e "/fetchFromGitHub/,/}/ s#sha256 = \".*\"#sha256 = \"$sha256\"#" \
-e "s#cargoSha256 = \".*\"#cargoSha256 = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"#" \ -e "s#cargoSha256 = \".*\"#cargoSha256 = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"#" \
--in-place ./default.nix --in-place ./default.nix
node_src="$(nix-build "$nixpkgs" -A rust-analyzer.src --no-out-link)/editors/code"
# Check vscode compatibility
req_vscode_ver="$(jq '.engines.vscode' "$node_src/package.json" --raw-output)"
req_vscode_ver="${req_vscode_ver#^}"
cur_vscode_ver="$(nix-instantiate --eval --strict "$nixpkgs" -A vscode.version | tr -d '"')"
if [[ "$(nix-instantiate --eval --strict -E "(builtins.compareVersions \"$req_vscode_ver\" \"$cur_vscode_ver\")")" -gt 0 ]]; then
echo "vscode $cur_vscode_ver is incompatible with the extension requiring ^$req_vscode_ver"
exit 1
fi
echo "Prebuilding for cargoSha256" echo "Prebuilding for cargoSha256"
cargo_sha256=$(nix-prefetch "{ sha256 }: (import $nixpkgs {}).rust-analyzer-unwrapped.cargoDeps.overrideAttrs (_: { outputHash = sha256; })") cargo_sha256=$(nix-prefetch "{ sha256 }: (import $nixpkgs {}).rust-analyzer-unwrapped.cargoDeps.overrideAttrs (_: { outputHash = sha256; })")
sed "s#cargoSha256 = \".*\"#cargoSha256 = \"$cargo_sha256\"#" \ sed "s#cargoSha256 = \".*\"#cargoSha256 = \"$cargo_sha256\"#" \
--in-place ./default.nix --in-place ./default.nix
# Update vscode extension
extension_ver=$(curl "https://github.com/rust-analyzer/rust-analyzer/releases/download/$ver/rust-analyzer.vsix" -L |
bsdtar -xf - --to-stdout extension/package.json | # Use bsdtar to extract vsix(zip).
jq --raw-output '.version')
echo "Extension version: $extension_ver"
build_deps="../../../../misc/vscode-extensions/rust-analyzer/build-deps"
# We need devDependencies to build vsix.
# `esbuild` is a binary package an is already in nixpkgs so we omit it here.
jq '{ name, version: $ver, dependencies: (.dependencies + .devDependencies | del(.esbuild)) }' "$node_src/package.json" \
--arg ver "$extension_ver" \
>"$build_deps/package.json.new"
old_deps="$(jq '.dependencies' "$build_deps"/package.json)"
new_deps="$(jq '.dependencies' "$build_deps"/package.json.new)"
if [[ "$old_deps" == "$new_deps" ]]; then
echo "package.json dependencies not changed, do simple version change"
sed -E '/^ "rust-analyzer-build-deps/,+3 s/version = ".*"/version = "'"$extension_ver"'"/' \
--in-place ../../../node-packages/node-packages.nix
mv "$build_deps"/package.json{.new,}
else
echo "package.json dependencies changed, updating nodePackages"
mv "$build_deps"/package.json{.new,}
pushd "../../../node-packages"
./generate.sh
popd
fi

View file

@ -1,5 +1,5 @@
# Update script: pkgs/development/tools/rust/rust-analyzer/update.sh
{ lib { lib
, fetchFromGitHub
, vscode-utils , vscode-utils
, jq , jq
, rust-analyzer , rust-analyzer
@ -15,14 +15,26 @@ let
pname = "rust-analyzer"; pname = "rust-analyzer";
publisher = "matklad"; publisher = "matklad";
# Use the plugin version as in vscode marketplace, updated by update script.
inherit (vsix) version;
releaseTag = "2021-11-29";
src = fetchFromGitHub {
owner = "rust-analyzer";
repo = "rust-analyzer";
rev = releaseTag;
sha256 = "sha256-vh7z8jupVxXPOko3sWUsOB7eji/7lKfwJ/CE3iw97Sw=";
};
build-deps = nodePackages."rust-analyzer-build-deps-../../misc/vscode-extensions/rust-analyzer/build-deps"; build-deps = nodePackages."rust-analyzer-build-deps-../../misc/vscode-extensions/rust-analyzer/build-deps";
# FIXME: Making a new derivation to link `node_modules` and run `npm run package` # FIXME: Making a new derivation to link `node_modules` and run `npm run package`
# will cause a build failure. # will cause a build failure.
vsix = build-deps.override { vsix = build-deps.override {
src = "${rust-analyzer.src}/editors/code"; src = "${src}/editors/code";
outputs = [ "vsix" "out" ]; outputs = [ "vsix" "out" ];
releaseTag = rust-analyzer.version; inherit releaseTag;
nativeBuildInputs = [ nativeBuildInputs = [
jq moreutils esbuild jq moreutils esbuild
@ -46,9 +58,6 @@ let
''; '';
}; };
# Use the plugin version as in vscode marketplace, updated by update script.
inherit (vsix) version;
in in
vscode-utils.buildVscodeExtension { vscode-utils.buildVscodeExtension {
inherit version vsix; inherit version vsix;
@ -68,7 +77,7 @@ vscode-utils.buildVscodeExtension {
description = "An alternative rust language server to the RLS"; description = "An alternative rust language server to the RLS";
homepage = "https://github.com/rust-analyzer/rust-analyzer"; homepage = "https://github.com/rust-analyzer/rust-analyzer";
license = with licenses; [ mit asl20 ]; license = with licenses; [ mit asl20 ];
maintainers = with maintainers; [ oxalica ]; maintainers = with maintainers; [ ];
platforms = platforms.all; platforms = platforms.all;
}; };
} }