2020-01-29 20:46:32 +01:00
|
|
|
# Update script: pkgs/development/tools/rust/rust-analyzer/update.sh
|
2021-01-25 09:26:54 +01:00
|
|
|
{ lib, vscode-utils, jq, rust-analyzer, nodePackages
|
2020-04-11 08:51:06 +02:00
|
|
|
, setDefaultServerPath ? true
|
2020-01-29 20:46:32 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
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-04-22 13:26:33 +02:00
|
|
|
build-deps = nodePackages."rust-analyzer-build-deps-../../misc/vscode-extensions/rust-analyzer/build-deps";
|
2020-04-11 08:51:06 +02:00
|
|
|
# FIXME: Making a new derivation to link `node_modules` and run `npm run package`
|
|
|
|
# will cause a build failure.
|
|
|
|
vsix = build-deps.override {
|
2020-01-29 20:46:32 +01:00
|
|
|
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}";
|
|
|
|
|
2020-04-11 08:51:06 +02:00
|
|
|
nativeBuildInputs = lib.optional setDefaultServerPath jq;
|
2020-01-29 20:46:32 +01:00
|
|
|
|
2020-06-01 13:36:40 +02:00
|
|
|
preInstall = lib.optionalString setDefaultServerPath ''
|
2020-01-29 20:46:32 +01:00
|
|
|
jq '.contributes.configuration.properties."rust-analyzer.serverPath".default = $s' \
|
|
|
|
--arg s "${rust-analyzer}/bin/rust-analyzer" \
|
2020-06-01 13:36:40 +02:00
|
|
|
package.json >package.json.new
|
|
|
|
mv package.json.new package.json
|
2020-01-29 20:46:32 +01: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;
|
|
|
|
};
|
|
|
|
}
|