push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,97 @@
{
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-08-25";
src = fetchFromGitHub {
owner = "rust-lang";
repo = "rust-analyzer";
tag = releaseTag;
hash = "sha256-apbJj2tsJkL2l+7Or9tJm1Mt5QPB6w/zIyDkCx8pfvk=";
};
vsix = buildNpmPackage {
inherit pname releaseTag;
version = lib.trim (lib.readFile ./version.txt);
src = "${src}/editors/code";
npmDepsHash = "sha256-fV4Z3jj+v56A7wbIEYhVAPVuAMqMds5xSe3OetWAsbw=";
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
# Ensure that the previous modification worked, by searching for the binary path
grep -Fq ${rust-analyzer}/bin/rust-analyzer package.json || {
echo "Modifying 'rust-analyzer.server.path' in 'package.json' failed."
exit 1
}
'';
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;
};
}

View File

@@ -0,0 +1,32 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq libarchive
#shellcheck shell=bash
set -euo pipefail
cd "$(dirname "$0")"
nixpkgs=../../../../../../
owner=rust-lang
repo=rust-analyzer
ver=$(
curl -s "https://api.github.com/repos/$owner/$repo/releases" |
jq 'map(select(.prerelease | not)) | .[0].tag_name' --raw-output
)
node_src="$(nix-build "$nixpkgs" -A rust-analyzer.src --no-out-link)/editors/code"
# Check vscode compatibility
req_vscode_ver="$(jq '.engines.vscode' "$node_src/package.json" --raw-output)"
req_vscode_ver="${req_vscode_ver#^}"
cur_vscode_ver="$(nix-instantiate --eval --strict "$nixpkgs" -A vscode.version | tr -d '"')"
if [[ "$(nix-instantiate --eval --strict -E "(builtins.compareVersions \"$req_vscode_ver\" \"$cur_vscode_ver\")")" -gt 0 ]]; then
echo "vscode $cur_vscode_ver is incompatible with the extension requiring ^$req_vscode_ver"
exit 1
fi
vsix_url="https://github.com/$owner/$repo/releases/download/$ver/rust-analyzer-linux-x64.vsix"
extension_ver=$(curl $vsix_url -L |
bsdtar -xf - --to-stdout extension/package.json | # Use bsdtar to extract vsix(zip).
jq --raw-output '.version')
echo $extension_ver > version.txt
echo "Extension version: $extension_ver"
echo "Remember to also update the releaseTag and hash in default.nix!"
echo "The releaseTag should be set to $ver"