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";
|
|
|
|
|
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" ];
|
|
|
|
|
2021-08-10 14:31:46 +00:00
|
|
|
releaseTag = rust-analyzer.version;
|
|
|
|
|
|
|
|
nativeBuildInputs = [ jq moreutils ];
|
|
|
|
|
|
|
|
# Follows https://github.com/rust-analyzer/rust-analyzer/blob/41949748a6123fd6061eb984a47f4fe780525e63/xtask/src/dist.rs#L39-L65
|
2020-04-24 23:36:52 +00:00
|
|
|
postInstall = ''
|
2021-08-10 14:31:46 +00:00
|
|
|
jq '
|
|
|
|
.version = $ENV.version |
|
|
|
|
.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
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-08-10 14:31:46 +00:00
|
|
|
# Use the plugin version as in vscode marketplace, updated by update script.
|
|
|
|
inherit (vsix) version;
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
}
|