vscode-extensions.rust-analyzer: use global NPM packages to share dependencies
This commit is contained in:
parent
e8d04d3797
commit
8318c36a4b
6 changed files with 45 additions and 2312 deletions
|
@ -142,6 +142,7 @@
|
|||
, "react-native-cli"
|
||||
, "react-tools"
|
||||
, "reveal.js"
|
||||
, { "rust-analyzer-build-deps": "../../misc/vscode-extensions/rust-analyzer/build-deps" }
|
||||
, "s3http"
|
||||
, "semver"
|
||||
, "serve"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl jq nix-prefetch nodePackages.node2nix
|
||||
#!nix-shell -i bash -p curl jq nix-prefetch
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
owner=rust-analyzer
|
||||
|
@ -46,23 +46,16 @@ sed "s/cargoSha256 = \".*\"/cargoSha256 = \"$cargo_sha256\"/" \
|
|||
|
||||
# Update vscode extension
|
||||
|
||||
echo "Generating node lock"
|
||||
pushd "$nixpkgs/pkgs/misc/vscode-extensions/rust-analyzer"
|
||||
ext_version=$(jq '.version' "$node_src/package.json" --raw-output)
|
||||
ext_publisher=$(jq '.publisher' "$node_src/package.json" --raw-output)
|
||||
echo "Extension version: $ext_version"
|
||||
[[ "$ext_publisher" == "matklad" ]]
|
||||
node2nix \
|
||||
--nodejs-12 \
|
||||
--development \
|
||||
--input "$node_src/package.json" \
|
||||
--lock "$node_src/package-lock.json" \
|
||||
--output ./node-packages.nix \
|
||||
--composition ./node-composition.nix \
|
||||
--no-copy-node-env \
|
||||
--node-env ../../../development/node-packages/node-env.nix
|
||||
sed -e 's_^.*src = [./]*/nix/store.*__g' \
|
||||
--in-place ./node-packages.nix
|
||||
sed -e "s/version = \".*\"/version = \"$ext_version\"/" \
|
||||
--in-place ./default.nix
|
||||
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" \
|
||||
>"$build_deps/package.json"
|
||||
|
||||
# FIXME: Lock the version of @type/vscode, the latest one (1.43.0) will cause build failure.
|
||||
vscode_lock_ver="$(jq '.dependencies."@types/vscode".version' --raw-output "$node_src/package-lock.json")"
|
||||
jq '.dependencies."@types/vscode" = "'$vscode_lock_ver'"' "$build_deps/package.json" >"$build_deps/package.json.new"
|
||||
mv "$build_deps"/package.json{.new,}
|
||||
|
||||
pushd "../../../node-packages"
|
||||
./generate.sh
|
||||
popd
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "rust-analyzer",
|
||||
"version": "0.4.0-dev",
|
||||
"dependencies": {
|
||||
"jsonc-parser": "^2.2.1",
|
||||
"node-fetch": "^2.6.0",
|
||||
"vscode-languageclient": "6.1.3",
|
||||
"@rollup/plugin-commonjs": "^11.0.2",
|
||||
"@rollup/plugin-node-resolve": "^7.1.1",
|
||||
"@types/node": "^12.12.34",
|
||||
"@types/node-fetch": "^2.5.5",
|
||||
"@types/vscode": "1.43.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.26.0",
|
||||
"@typescript-eslint/parser": "^2.26.0",
|
||||
"eslint": "^6.8.0",
|
||||
"rollup": "^2.3.2",
|
||||
"tslib": "^1.11.1",
|
||||
"typescript": "^3.8.3",
|
||||
"typescript-formatter": "^7.2.2",
|
||||
"vsce": "^1.75.0"
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
# Update script: pkgs/development/tools/rust/rust-analyzer/update.sh
|
||||
{ lib, pkgs, stdenv, nodejs, vscode-utils, jq, rust-analyzer
|
||||
, setDefaultRaLspServerPath ? true
|
||||
{ lib, stdenv, vscode-utils, jq, rust-analyzer, nodePackages_10_x
|
||||
, setDefaultServerPath ? true
|
||||
}:
|
||||
|
||||
let
|
||||
|
@ -10,10 +10,10 @@ let
|
|||
# Follow the unstable version of rust-analyzer, since the extension is not stable yet.
|
||||
inherit (rust-analyzer) version;
|
||||
|
||||
vsix = (import ./node-composition.nix {
|
||||
inherit pkgs nodejs;
|
||||
inherit (stdenv.hostPlatform) system;
|
||||
}).package.override {
|
||||
build-deps = nodePackages_10_x."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.
|
||||
vsix = build-deps.override {
|
||||
src = "${rust-analyzer.src}/editors/code";
|
||||
outputs = [ "vsix" "out" ];
|
||||
|
||||
|
@ -30,10 +30,10 @@ in vscode-utils.buildVscodeExtension {
|
|||
src = "${vsix}/${pname}.zip";
|
||||
vscodeExtUniqueId = "${publisher}.${pname}";
|
||||
|
||||
nativeBuildInputs = lib.optional setDefaultRaLspServerPath jq;
|
||||
nativeBuildInputs = lib.optional setDefaultServerPath jq;
|
||||
|
||||
postFixup = lib.optionalString setDefaultRaLspServerPath ''
|
||||
package_json="$out/share/vscode/extensions/${publisher}.${pname}/package.json"
|
||||
postFixup = lib.optionalString setDefaultServerPath ''
|
||||
package_json="$out/${publisher}.${pname}/package.json"
|
||||
jq '.contributes.configuration.properties."rust-analyzer.serverPath".default = $s' \
|
||||
--arg s "${rust-analyzer}/bin/rust-analyzer" \
|
||||
$package_json >$package_json.new
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
# This file has been generated by node2nix 1.8.0. Do not edit!
|
||||
|
||||
{pkgs ? import <nixpkgs> {
|
||||
inherit system;
|
||||
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-12_x"}:
|
||||
|
||||
let
|
||||
nodeEnv = import ../../../development/node-packages/node-env.nix {
|
||||
inherit (pkgs) stdenv python2 utillinux runCommand writeTextFile;
|
||||
inherit nodejs;
|
||||
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
|
||||
};
|
||||
in
|
||||
import ./node-packages.nix {
|
||||
inherit (pkgs) fetchurl fetchgit;
|
||||
inherit nodeEnv;
|
||||
}
|
2266
pkgs/misc/vscode-extensions/rust-analyzer/node-packages.nix
generated
2266
pkgs/misc/vscode-extensions/rust-analyzer/node-packages.nix
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue