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 {
|
"rust-analyzer-build-deps-../../misc/vscode-extensions/rust-analyzer/build-deps" = nodeEnv.buildNodePackage {
|
||||||
name = "rust-analyzer";
|
name = "rust-analyzer";
|
||||||
packageName = "rust-analyzer";
|
packageName = "rust-analyzer";
|
||||||
version = "0.4.0-dev";
|
version = "0.2.694";
|
||||||
src = ../../misc/vscode-extensions/rust-analyzer/build-deps;
|
src = ../../misc/vscode-extensions/rust-analyzer/build-deps;
|
||||||
dependencies = [
|
dependencies = [
|
||||||
sources."@babel/code-frame-7.12.11"
|
sources."@babel/code-frame-7.12.11"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env nix-shell
|
#!/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
|
set -euo pipefail
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
owner=rust-analyzer
|
owner=rust-analyzer
|
||||||
|
@ -46,19 +46,31 @@ sed "s#cargoSha256 = \".*\"#cargoSha256 = \"$cargo_sha256\"#" \
|
||||||
|
|
||||||
# Update vscode extension
|
# 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"
|
build_deps="../../../../misc/vscode-extensions/rust-analyzer/build-deps"
|
||||||
# We need devDependencies to build vsix.
|
# 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"
|
>"$build_deps/package.json.new"
|
||||||
|
|
||||||
# FIXME: rollup@2.55.0 breaks the build: https://github.com/rollup/rollup/issues/4195
|
# 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"
|
sed 's/"rollup": ".*"/"rollup": "=2.51.1"/' --in-place "$build_deps/package.json.new"
|
||||||
|
|
||||||
if cmp --quiet "$build_deps"/package.json{.new,}; then
|
old_deps="$(jq '.dependencies' "$build_deps"/package.json)"
|
||||||
echo "package.json not changed, skip updating nodePackages"
|
new_deps="$(jq '.dependencies' "$build_deps"/package.json.new)"
|
||||||
rm "$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
|
else
|
||||||
echo "package.json changed, updating nodePackages"
|
echo "package.json dependencies changed, updating nodePackages"
|
||||||
mv "$build_deps"/package.json{.new,}
|
mv "$build_deps"/package.json{.new,}
|
||||||
|
|
||||||
pushd "../../../node-packages"
|
pushd "../../../node-packages"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "rust-analyzer",
|
"name": "rust-analyzer",
|
||||||
"version": "0.4.0-dev",
|
"version": "0.2.694",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"https-proxy-agent": "^5.0.0",
|
"https-proxy-agent": "^5.0.0",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
|
|
|
@ -12,9 +12,6 @@ let
|
||||||
pname = "rust-analyzer";
|
pname = "rust-analyzer";
|
||||||
publisher = "matklad";
|
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";
|
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.
|
||||||
|
@ -22,13 +19,27 @@ let
|
||||||
src = "${rust-analyzer.src}/editors/code";
|
src = "${rust-analyzer.src}/editors/code";
|
||||||
outputs = [ "vsix" "out" ];
|
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 = ''
|
postInstall = ''
|
||||||
npm run package
|
jq '
|
||||||
mkdir $vsix
|
.version = $ENV.version |
|
||||||
cp ${pname}.vsix $vsix/${pname}.zip
|
.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
|
in
|
||||||
vscode-utils.buildVscodeExtension {
|
vscode-utils.buildVscodeExtension {
|
||||||
inherit version vsix;
|
inherit version vsix;
|
||||||
|
|
Loading…
Reference in a new issue