2020-04-24 23:36:52 +00:00
|
|
|
# Update script: pkgs/development/tools/rust/rust-analyzer/update.sh
|
2021-08-08 23:34:03 +00:00
|
|
|
{ lib
|
|
|
|
, vscode-utils
|
|
|
|
, jq
|
|
|
|
, rust-analyzer
|
|
|
|
, nodePackages
|
2020-04-24 23:36:52 +00:00
|
|
|
, setDefaultServerPath ? true
|
2021-08-08 23:34:03 +00:00
|
|
|
, moreutils
|
2020-04-24 23:36:52 +00: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-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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-08-08 23:34:03 +00:00
|
|
|
in
|
|
|
|
vscode-utils.buildVscodeExtension {
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit version vsix;
|
|
|
|
name = "${pname}-${version}";
|
|
|
|
src = "${vsix}/${pname}.zip";
|
|
|
|
vscodeExtUniqueId = "${publisher}.${pname}";
|
|
|
|
|
2021-08-08 23:34:03 +00:00
|
|
|
nativeBuildInputs = lib.optionals setDefaultServerPath [ jq moreutils ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
preInstall = lib.optionalString setDefaultServerPath ''
|
2021-08-08 23:34:03 +00:00
|
|
|
jq '.contributes.configuration.properties."rust-analyzer.server.path".default = $s' \
|
2020-04-24 23:36:52 +00:00
|
|
|
--arg s "${rust-analyzer}/bin/rust-analyzer" \
|
2021-08-08 23:34:03 +00:00
|
|
|
package.json | sponge 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;
|
|
|
|
};
|
|
|
|
}
|