From b7ddfc914dc19132da8d1d3cdb581da3dc87dd82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charlotte=20=F0=9F=A6=9D=20Dele=C5=84kec?= Date: Tue, 18 Feb 2025 08:54:33 +0100 Subject: [PATCH] vscode-extensions.rust-lang.rust-analyzer: move to buildNpmPackage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The existing node2nix-based build was broken with #382557. I could not salvage it, however apparently it is considered the deprecated way of building node packages in nixpkgs. This commit moves rust-analyzer’s vsix build to buildNpmPackage. Fixes: #382845 Part-Of: #229475 --- .../build-deps/package.json | 24 ---------------- .../rust-lang.rust-analyzer/default.nix | 28 ++++++++----------- .../rust-lang.rust-analyzer/update.sh | 23 +-------------- .../rust-lang.rust-analyzer/version.txt | 1 + 4 files changed, 14 insertions(+), 62 deletions(-) delete mode 100644 pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/build-deps/package.json create mode 100644 pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/version.txt diff --git a/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/build-deps/package.json b/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/build-deps/package.json deleted file mode 100644 index 3e7688f0e068..000000000000 --- a/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/build-deps/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "rust-analyzer", - "version": "0.3.2029", - "dependencies": { - "@hpcc-js/wasm": "^2.13.0", - "anser": "^2.1.1", - "d3": "^7.8.5", - "d3-graphviz": "^5.0.2", - "vscode-languageclient": "^8.1.0", - "@tsconfig/strictest": "^2.0.1", - "@types/node": "~16.11.7", - "@types/vscode": "~1.78.1", - "@typescript-eslint/eslint-plugin": "^6.0.0", - "@typescript-eslint/parser": "^6.0.0", - "@vscode/test-electron": "^2.3.8", - "@vscode/vsce": "^2.19.0", - "eslint": "^8.44.0", - "eslint-config-prettier": "^8.8.0", - "ovsx": "^0.8.2", - "prettier": "^3.0.0", - "tslib": "^2.6.0", - "typescript": "^5.1.6" - } -} diff --git a/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/default.nix b/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/default.nix index bcb076135ae1..e1318e4f43ec 100644 --- a/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/default.nix +++ b/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/default.nix @@ -1,10 +1,11 @@ { + pkgsBuildBuild, lib, fetchFromGitHub, vscode-utils, jq, rust-analyzer, - nodePackages, + buildNpmPackage, moreutils, esbuild, pkg-config, @@ -30,19 +31,14 @@ let hash = "sha256-STmaV9Zu74QtkGGrbr9uMhskwagfCjJqOAYapXabiuk="; }; - build-deps = - nodePackages."rust-analyzer-build-deps-../../applications/editors/vscode/extensions/rust-lang.rust-analyzer/build-deps"; - # FIXME: Making a new derivation to link `node_modules` and run `npm run package` - # will cause a build failure. - vsix = build-deps.override { + vsix = buildNpmPackage { + inherit pname releaseTag; + version = lib.trim (lib.readFile ./version.txt); src = "${src}/editors/code"; - outputs = [ - "vsix" - "out" + npmDepsHash = "sha256-EtkgnNOAKDQP7BDHI667SPu73tYrz1Hq6TmeeObXnf4="; + buildInputs = [ + pkgsBuildBuild.libsecret ]; - - inherit releaseTag; - nativeBuildInputs = [ jq @@ -50,7 +46,6 @@ let esbuild # Required by `keytar`, which is a dependency of `vsce`. pkg-config - libsecret ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.apple_sdk.frameworks.AppKit @@ -58,7 +53,7 @@ let ]; # Follows https://github.com/rust-lang/rust-analyzer/blob/41949748a6123fd6061eb984a47f4fe780525e63/xtask/src/dist.rs#L39-L65 - postRebuild = '' + installPhase = '' jq ' .version = $ENV.version | .releaseTag = $ENV.releaseTag | @@ -66,10 +61,11 @@ let walk(del(.["$generated-start"]?) | del(.["$generated-end"]?)) ' package.json | sponge package.json - mkdir -p $vsix - npx vsce package -o $vsix/${pname}.zip + mkdir -p $out + npx vsce package -o $out/${pname}.zip ''; }; + in vscode-utils.buildVscodeExtension { inherit version vsix pname; diff --git a/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/update.sh b/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/update.sh index fbf62c3b9db4..3ccf27d81f81 100755 --- a/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/update.sh +++ b/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/update.sh @@ -4,7 +4,6 @@ set -euo pipefail cd "$(dirname "$0")" nixpkgs=../../../../../../ -node_packages="$nixpkgs/pkgs/development/node-packages" owner=rust-lang repo=rust-analyzer ver=$( @@ -25,27 +24,7 @@ fi extension_ver=$(curl "https://github.com/$owner/$repo/releases/download/$ver/rust-analyzer-linux-x64.vsix" -L | bsdtar -xf - --to-stdout extension/package.json | # Use bsdtar to extract vsix(zip). jq --raw-output '.version') +echo -n $extension_ver > version.txt echo "Extension version: $extension_ver" -# We need devDependencies to build vsix. -# `esbuild` is a binary package an is already in nixpkgs so we omit it here. -jq '{ name, version: $ver, dependencies: (.dependencies + .devDependencies | del(.esbuild)) }' "$node_src/package.json" \ - --arg ver "$extension_ver" \ - >"build-deps/package.json.new" - -old_deps="$(jq '.dependencies' build-deps/package.json)" -new_deps="$(jq '.dependencies' build-deps/package.json.new)" -if [[ "$old_deps" == "$new_deps" ]]; then - echo "package.json dependencies not changed, do simple version change" - - sed -E '/^ "rust-analyzer-build-deps/,+3 s/version = ".*"/version = "'"$extension_ver"'"/' \ - --in-place "$node_packages"/node-packages.nix - mv build-deps/package.json{.new,} -else - echo "package.json dependencies changed, updating nodePackages" - mv build-deps/package.json{.new,} - - ./"$node_packages"/generate.sh -fi - echo "Remember to also update the releaseTag and hash in default.nix!" diff --git a/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/version.txt b/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/version.txt new file mode 100644 index 000000000000..97f29c933097 --- /dev/null +++ b/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/version.txt @@ -0,0 +1 @@ +0.3.2029