From 246146fb401a0e9e30c27d019489c60dc545c6fc Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Mon, 3 Mar 2025 15:32:44 -0500 Subject: [PATCH] rescript-editor-analysis: refactor Use the Dune builder rather than than a generic derivation. --- .../chenglou92.rescript-vscode/default.nix | 17 ++++++++++--- .../rescript-editor-analysis.nix | 24 ++++++------------- .../re/rescript-language-server/package.nix | 2 +- pkgs/top-level/all-packages.nix | 7 +++--- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pkgs/applications/editors/vscode/extensions/chenglou92.rescript-vscode/default.nix b/pkgs/applications/editors/vscode/extensions/chenglou92.rescript-vscode/default.nix index 3ac8aa007334..f2e247b2e57f 100644 --- a/pkgs/applications/editors/vscode/extensions/chenglou92.rescript-vscode/default.nix +++ b/pkgs/applications/editors/vscode/extensions/chenglou92.rescript-vscode/default.nix @@ -5,8 +5,16 @@ callPackage, }: let - version = "1.62.0"; - rescript-editor-analysis = callPackage ./rescript-editor-analysis.nix { inherit version; }; + extVersion = "1.62.0"; + rescript-editor-analysis = callPackage ./rescript-editor-analysis.nix { }; + + # Ensure the versions match + version = + if rescript-editor-analysis.version == extVersion then + rescript-editor-analysis.version + else + throw "analysis and extension versions must match"; + arch = if stdenv.hostPlatform.isLinux then "linux" @@ -16,7 +24,8 @@ let throw "Unsupported system: ${stdenv.system}"; analysisDir = "server/analysis_binaries/${arch}"; in -vscode-utils.buildVscodeMarketplaceExtension rec { + +vscode-utils.buildVscodeMarketplaceExtension { mktplcRef = { name = "rescript-vscode"; publisher = "chenglou92"; @@ -27,6 +36,7 @@ vscode-utils.buildVscodeMarketplaceExtension rec { # For rescript-language-server passthru.rescript-editor-analysis = rescript-editor-analysis; + strictDeps = true; postPatch = '' rm -r ${analysisDir} ln -s ${rescript-editor-analysis}/bin ${analysisDir} @@ -39,6 +49,7 @@ vscode-utils.buildVscodeMarketplaceExtension rec { lib.maintainers.dlip lib.maintainers.jayesh-bhoot ]; + platforms = lib.platforms.linux ++ lib.platforms.darwin; license = lib.licenses.mit; }; } diff --git a/pkgs/applications/editors/vscode/extensions/chenglou92.rescript-vscode/rescript-editor-analysis.nix b/pkgs/applications/editors/vscode/extensions/chenglou92.rescript-vscode/rescript-editor-analysis.nix index b4763dc417a1..718d14a52851 100644 --- a/pkgs/applications/editors/vscode/extensions/chenglou92.rescript-vscode/rescript-editor-analysis.nix +++ b/pkgs/applications/editors/vscode/extensions/chenglou92.rescript-vscode/rescript-editor-analysis.nix @@ -1,16 +1,14 @@ { lib, - stdenv, fetchFromGitHub, - ocaml, ocamlPackages, - dune_3, - version, }: -stdenv.mkDerivation { - pname = "rescript-editor-analysis"; - inherit version; +ocamlPackages.buildDunePackage rec { + pname = "analysis"; + version = "1.62.0"; + + minimalOCamlVersion = "4.10"; src = fetchFromGitHub { owner = "rescript-lang"; @@ -19,20 +17,11 @@ stdenv.mkDerivation { hash = "sha256-v+qCVge57wvA97mtzbxAX9Fvi7ruo6ZyIC14O8uWl9Y="; }; + strictDeps = true; nativeBuildInputs = [ - ocaml - dune_3 ocamlPackages.cppo ]; - buildPhase = '' - dune build -p analysis - ''; - - installPhase = '' - install -D -m0555 _build/default/analysis/bin/main.exe $out/bin/rescript-editor-analysis.exe - ''; - meta = { description = "Analysis binary for the ReScript VSCode plugin"; homepage = "https://github.com/rescript-lang/rescript-vscode"; @@ -41,5 +30,6 @@ stdenv.mkDerivation { lib.maintainers.jayesh-bhoot ]; license = lib.licenses.mit; + mainProgram = "rescript-editor-analysis"; }; } diff --git a/pkgs/by-name/re/rescript-language-server/package.nix b/pkgs/by-name/re/rescript-language-server/package.nix index ab398cee3c10..5e700b3c18da 100644 --- a/pkgs/by-name/re/rescript-language-server/package.nix +++ b/pkgs/by-name/re/rescript-language-server/package.nix @@ -43,7 +43,7 @@ buildNpmPackage rec { # https://github.com/rescript-lang/rescript-vscode/blob/1.62.0/.github/workflows/ci.yml#L182-L183 mkdir analysis_binaries/${platformDir} - cp ${rescript-editor-analysis}/bin/* analysis_binaries/${platformDir}/ + cp ${lib.getExe rescript-editor-analysis} analysis_binaries/${platformDir}/ # https://github.com/rescript-lang/rescript-vscode/blob/1.62.0/package.json#L252 esbuild src/cli.ts --bundle --sourcemap --outfile=out/cli.js --format=cjs --platform=node --loader:.node=file --minify diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index cf50f2cfdd02..a82753e243e2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8173,10 +8173,9 @@ with pkgs; inherit (callPackage ../development/tools/replay-io { }) replay-io replay-node-cli; - rescript-language-server = let - version = "1.62.0"; - rescript-editor-analysis = callPackage ../applications/editors/vscode/extensions/chenglou92.rescript-vscode/rescript-editor-analysis.nix { inherit version; }; - in callPackage ../by-name/re/rescript-language-server/package.nix { inherit rescript-editor-analysis; }; + rescript-language-server = callPackage ../by-name/re/rescript-language-server/package.nix { + rescript-editor-analysis = vscode-extensions.chenglou92.rescript-vscode.rescript-editor-analysis; + }; rnginline = with python3Packages; toPythonApplication rnginline;