From b8700931406ffe530c4a6f61f5a04066ff8d6e2c Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Tue, 4 Mar 2025 14:07:57 -0500 Subject: [PATCH 1/3] maintainers: add RossSmyth --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index e5c5c781d5a1..d6d45e34dd10 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -20326,6 +20326,12 @@ githubId = 19699320; keys = [ { fingerprint = "FD5D F7A8 85BB 378A 0157 5356 B09C 4220 3566 9AF8"; } ]; }; + RossSmyth = { + name = "Ross Smyth"; + matrix = "@rosssmyth:matrix.org"; + github = "RossSmyth"; + githubId = 18294397; + }; rostan-t = { name = "Rostan Tabet"; email = "rostan.tabet@gmail.com"; From ef92c406941ad6cf93ac35a0903c4c978c948934 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Mon, 3 Mar 2025 15:32:39 -0500 Subject: [PATCH 2/3] rescript-language-server: init at 1.62.0 --- .../chenglou92.rescript-vscode/default.nix | 4 ++ .../re/rescript-language-server/package.nix | 71 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 5 ++ 3 files changed, 80 insertions(+) create mode 100644 pkgs/by-name/re/rescript-language-server/package.nix 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 c77c1ea30f2a..3ac8aa007334 100644 --- a/pkgs/applications/editors/vscode/extensions/chenglou92.rescript-vscode/default.nix +++ b/pkgs/applications/editors/vscode/extensions/chenglou92.rescript-vscode/default.nix @@ -23,6 +23,10 @@ vscode-utils.buildVscodeMarketplaceExtension rec { inherit version; hash = "sha256-yUAhysTM9FXo9ZAzrto+tnjnofIUEQAGBg3tjIainrY="; }; + + # For rescript-language-server + passthru.rescript-editor-analysis = rescript-editor-analysis; + postPatch = '' rm -r ${analysisDir} ln -s ${rescript-editor-analysis}/bin ${analysisDir} diff --git a/pkgs/by-name/re/rescript-language-server/package.nix b/pkgs/by-name/re/rescript-language-server/package.nix new file mode 100644 index 000000000000..ab398cee3c10 --- /dev/null +++ b/pkgs/by-name/re/rescript-language-server/package.nix @@ -0,0 +1,71 @@ +{ + lib, + stdenv, + buildNpmPackage, + fetchFromGitHub, + esbuild, + nix-update-script, + versionCheckHook, + rescript-editor-analysis, +}: +let + version = "1.62.0"; + + platformDir = + if stdenv.hostPlatform.isLinux then + "linux" + else if stdenv.hostPlatform.isDarwin then + "darwin" + else + throw "Unsupported system: ${stdenv.system}"; +in +buildNpmPackage rec { + pname = "rescript-language-server"; + inherit version; + + src = fetchFromGitHub { + owner = "rescript-lang"; + repo = "rescript-vscode"; + tag = version; + hash = "sha256-Tox5Qq0Kpqikac90sQww2cGr9RHlXnVy7GMnRA18CoA="; + }; + + sourceRoot = "${src.name}/server"; + npmDepsHash = "sha256-Qi41qDJ0WR0QWw7guhuz1imT51SqI7mORGjNbmZWnio="; + + strictDeps = true; + nativeBuildInputs = [ esbuild ]; + + # Tries to do funny things (install all packages for the entire repo) if you don't override it. This is just a copy paste + # from the package.json. + buildPhase = '' + runHook preBuild + + # 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}/ + + # 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 + + runHook postBuild + ''; + + nativeInstallCheckInputs = [ + versionCheckHook + ]; + versionCheckProgramArg = [ "--version" ]; + doInstallCheck = true; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "ReScript Language Server"; + homepage = "https://github.com/rescript-lang/rescript-vscode/tree/${version}/server"; + changelog = "https://github.com/rescript-lang/rescript-vscode/releases/tag/${version}"; + mainProgram = "rescript-language-server"; + license = lib.licenses.mit; + platforms = lib.platforms.linux ++ lib.platforms.darwin; + maintainers = [ lib.maintainers.RossSmyth ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 136839c9fc49..cf50f2cfdd02 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8173,6 +8173,11 @@ 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; }; + rnginline = with python3Packages; toPythonApplication rnginline; rr = callPackage ../development/tools/analysis/rr { }; 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 3/3] 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;