nixpkgs/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/default.nix
Ihar Hrachyshka dd0f03a56c treewide: remove usage of deprecated apple_sdk framework stubs
They are not doing anything right now. This is in preparation for their
complete removal from the tree.

Note: several changes that affect the derivation inputs (e.g. removal of
references to stub paths in build instructions) were left out. They will
be cleaned up the next iteration and will require special care.

Note: this PR is a result of a mix of ugly regex (not AST) based
automation and some manual labor. For reference, the regex automation
part was hacked in: https://github.com/booxter/nix-clean-apple_sdk

Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
2025-04-19 20:28:20 -04:00

91 lines
2.2 KiB
Nix

{
pkgsBuildBuild,
lib,
fetchFromGitHub,
vscode-utils,
jq,
rust-analyzer,
buildNpmPackage,
moreutils,
esbuild,
pkg-config,
libsecret,
setDefaultServerPath ? true,
}:
let
pname = "rust-analyzer";
publisher = "rust-lang";
# Use the plugin version as in vscode marketplace, updated by update script.
inherit (vsix) version;
releaseTag = "2025-02-17";
src = fetchFromGitHub {
owner = "rust-lang";
repo = "rust-analyzer";
rev = releaseTag;
hash = "sha256-i76MMFSkCr4kDwurK8CACwZq7qEgVEgIzkOr2kiuAKk=";
};
vsix = buildNpmPackage {
inherit pname releaseTag;
version = lib.trim (lib.readFile ./version.txt);
src = "${src}/editors/code";
npmDepsHash = "sha256-0frOGphtzO6z8neSEYfjyRYrM6zEO3wId/TACblZkxM=";
buildInputs = [
pkgsBuildBuild.libsecret
];
nativeBuildInputs = [
jq
moreutils
esbuild
# Required by `keytar`, which is a dependency of `vsce`.
pkg-config
];
# Follows https://github.com/rust-lang/rust-analyzer/blob/41949748a6123fd6061eb984a47f4fe780525e63/xtask/src/dist.rs#L39-L65
installPhase = ''
jq '
.version = $ENV.version |
.releaseTag = $ENV.releaseTag |
.enableProposedApi = false |
walk(del(.["$generated-start"]?) | del(.["$generated-end"]?))
' package.json | sponge package.json
mkdir -p $out
npx vsce package -o $out/${pname}.zip
'';
};
in
vscode-utils.buildVscodeExtension {
inherit version vsix pname;
src = "${vsix}/${pname}.zip";
vscodeExtUniqueId = "${publisher}.${pname}";
vscodeExtPublisher = publisher;
vscodeExtName = pname;
nativeBuildInputs = lib.optionals setDefaultServerPath [
jq
moreutils
];
preInstall = lib.optionalString setDefaultServerPath ''
jq '(.contributes.configuration[] | select(.title == "server") | .properties."rust-analyzer.server.path".default) = $s' \
--arg s "${rust-analyzer}/bin/rust-analyzer" \
package.json | sponge package.json
'';
meta = {
description = "Alternative rust language server to the RLS";
homepage = "https://github.com/rust-lang/rust-analyzer";
license = [
lib.licenses.mit
lib.licenses.asl20
];
maintainers = [ ];
platforms = lib.platforms.all;
};
}