2020-04-24 23:36:52 +00:00
|
|
|
# Update script: pkgs/development/tools/rust/rust-analyzer/update.sh
|
2021-02-05 17:12:51 +00:00
|
|
|
{ lib, vscode-utils, jq, rust-analyzer, nodePackages
|
2020-04-24 23:36:52 +00:00
|
|
|
, setDefaultServerPath ? true
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pname = "rust-analyzer";
|
|
|
|
publisher = "matklad";
|
|
|
|
|
|
|
|
# Follow the unstable version of rust-analyzer, since the extension is not stable yet.
|
|
|
|
inherit (rust-analyzer) version;
|
|
|
|
|
2020-06-02 18:00:15 +00:00
|
|
|
build-deps = nodePackages."rust-analyzer-build-deps-../../misc/vscode-extensions/rust-analyzer/build-deps";
|
2020-04-24 23:36:52 +00:00
|
|
|
# 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" ];
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
npm run package
|
|
|
|
mkdir $vsix
|
|
|
|
cp ${pname}.vsix $vsix/${pname}.zip
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in vscode-utils.buildVscodeExtension {
|
|
|
|
inherit version vsix;
|
|
|
|
name = "${pname}-${version}";
|
|
|
|
src = "${vsix}/${pname}.zip";
|
|
|
|
vscodeExtUniqueId = "${publisher}.${pname}";
|
|
|
|
|
|
|
|
nativeBuildInputs = lib.optional setDefaultServerPath jq;
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
preInstall = lib.optionalString setDefaultServerPath ''
|
2020-04-24 23:36:52 +00:00
|
|
|
jq '.contributes.configuration.properties."rust-analyzer.serverPath".default = $s' \
|
|
|
|
--arg s "${rust-analyzer}/bin/rust-analyzer" \
|
2020-06-18 07:06:33 +00:00
|
|
|
package.json >package.json.new
|
|
|
|
mv package.json.new package.json
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "An alternative rust language server to the RLS";
|
|
|
|
homepage = "https://github.com/rust-analyzer/rust-analyzer";
|
|
|
|
license = with licenses; [ mit asl20 ];
|
|
|
|
maintainers = with maintainers; [ oxalica ];
|
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|