vscode-extensions.matklad.rust-analyzer: use extension version and apply patches
This commit is contained in:
parent
44b130d392
commit
cd9ed036d6
2
pkgs/development/node-packages/node-packages.nix
generated
2
pkgs/development/node-packages/node-packages.nix
generated
@ -111001,7 +111001,7 @@ in
|
||||
"rust-analyzer-build-deps-../../misc/vscode-extensions/rust-analyzer/build-deps" = nodeEnv.buildNodePackage {
|
||||
name = "rust-analyzer";
|
||||
packageName = "rust-analyzer";
|
||||
version = "0.4.0-dev";
|
||||
version = "0.2.694";
|
||||
src = ../../misc/vscode-extensions/rust-analyzer/build-deps;
|
||||
dependencies = [
|
||||
sources."@babel/code-frame-7.12.11"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl jq nix-prefetch
|
||||
#!nix-shell -i bash -p curl jq nix-prefetch libarchive
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
owner=rust-analyzer
|
||||
@ -46,19 +46,31 @@ sed "s#cargoSha256 = \".*\"#cargoSha256 = \"$cargo_sha256\"#" \
|
||||
|
||||
# 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.
|
||||
jq '{ name, version, dependencies: (.dependencies + .devDependencies) }' "$node_src/package.json" \
|
||||
jq '{ name, version: $ver, dependencies: (.dependencies + .devDependencies) }' "$node_src/package.json" \
|
||||
--arg ver "$extension_ver" \
|
||||
>"$build_deps/package.json.new"
|
||||
|
||||
# FIXME: rollup@2.55.0 breaks the build: https://github.com/rollup/rollup/issues/4195
|
||||
sed 's/"rollup": ".*"/"rollup": "=2.51.1"/' --in-place "$build_deps/package.json.new"
|
||||
|
||||
if cmp --quiet "$build_deps"/package.json{.new,}; then
|
||||
echo "package.json not changed, skip updating nodePackages"
|
||||
rm "$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 changed, updating nodePackages"
|
||||
echo "package.json dependencies changed, updating nodePackages"
|
||||
mv "$build_deps"/package.json{.new,}
|
||||
|
||||
pushd "../../../node-packages"
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rust-analyzer",
|
||||
"version": "0.4.0-dev",
|
||||
"version": "0.2.694",
|
||||
"dependencies": {
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
|
@ -12,9 +12,6 @@ let
|
||||
pname = "rust-analyzer";
|
||||
publisher = "matklad";
|
||||
|
||||
# Follow the unstable version of rust-analyzer, since the extension is not stable yet.
|
||||
inherit (rust-analyzer) version;
|
||||
|
||||
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`
|
||||
# will cause a build failure.
|
||||
@ -22,13 +19,27 @@ let
|
||||
src = "${rust-analyzer.src}/editors/code";
|
||||
outputs = [ "vsix" "out" ];
|
||||
|
||||
releaseTag = rust-analyzer.version;
|
||||
|
||||
nativeBuildInputs = [ jq moreutils ];
|
||||
|
||||
# Follows https://github.com/rust-analyzer/rust-analyzer/blob/41949748a6123fd6061eb984a47f4fe780525e63/xtask/src/dist.rs#L39-L65
|
||||
postInstall = ''
|
||||
npm run package
|
||||
mkdir $vsix
|
||||
cp ${pname}.vsix $vsix/${pname}.zip
|
||||
jq '
|
||||
.version = $ENV.version |
|
||||
.releaseTag = $ENV.releaseTag |
|
||||
.enableProposedApi = false |
|
||||
walk(del(.["$generated-start"]?) | del(.["$generated-end"]?))
|
||||
' package.json | sponge package.json
|
||||
|
||||
mkdir -p $vsix
|
||||
npx vsce package -o $vsix/${pname}.zip
|
||||
'';
|
||||
};
|
||||
|
||||
# Use the plugin version as in vscode marketplace, updated by update script.
|
||||
inherit (vsix) version;
|
||||
|
||||
in
|
||||
vscode-utils.buildVscodeExtension {
|
||||
inherit version vsix;
|
||||
|
Loading…
Reference in New Issue
Block a user