From f4538767542c5d6330d40a4fd10c1414b8315c60 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Mon, 23 Jun 2025 15:07:01 -0400 Subject: [PATCH 1/2] rescript-language-server: Fix updateScript --- .../rescript-editor-analysis.nix | 20 ++++++++++++++----- .../re/rescript-language-server/package.nix | 13 ++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) 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 718d14a52851..7232795a8148 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,6 +1,7 @@ { lib, fetchFromGitHub, + nix-update-script, ocamlPackages, }: @@ -13,8 +14,8 @@ ocamlPackages.buildDunePackage rec { src = fetchFromGitHub { owner = "rescript-lang"; repo = "rescript-vscode"; - rev = version; - hash = "sha256-v+qCVge57wvA97mtzbxAX9Fvi7ruo6ZyIC14O8uWl9Y="; + tag = version; + hash = "sha256-Tox5Qq0Kpqikac90sQww2cGr9RHlXnVy7GMnRA18CoA="; }; strictDeps = true; @@ -22,12 +23,21 @@ ocamlPackages.buildDunePackage rec { ocamlPackages.cppo ]; + passthru.updateScript = nix-update-script { + extraArgs = [ + "--version-regex" + "([0-9]+\.[0-9]+\.[0-9]+)" + ]; + }; + meta = { description = "Analysis binary for the ReScript VSCode plugin"; homepage = "https://github.com/rescript-lang/rescript-vscode"; - maintainers = [ - lib.maintainers.dlip - lib.maintainers.jayesh-bhoot + changelog = "https://github.com/rescript-lang/rescript-vscode/releases/tag/${version}"; + maintainers = with lib.maintainers; [ + dlip + jayesh-bhoot + RossSmyth ]; 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 b2042cfdbb08..ea7a87e5f530 100644 --- a/pkgs/by-name/re/rescript-language-server/package.nix +++ b/pkgs/by-name/re/rescript-language-server/package.nix @@ -20,18 +20,13 @@ let throw "Unsupported system: ${stdenv.system}"; in buildNpmPackage rec { + # These have the same source, and must be the same version. + inherit (rescript-editor-analysis) src; 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="; + npmDepsHash = "sha256-Qi41qDJ0WR0QWw7guhuz1imT51SqI7mORGjNbmZWnio"; strictDeps = true; nativeBuildInputs = [ esbuild ]; @@ -57,7 +52,7 @@ buildNpmPackage rec { versionCheckProgramArg = "--version"; doInstallCheck = true; - passthru.updateScript = nix-update-script { }; + passthru.updateScript = nix-update-script { extraArgs = [ "--version-regex" "([0-9]\.[0-9][0-9]\.[0-9])"]; }; meta = { description = "ReScript Language Server"; From b814e94cacf063d3e30093656bcd90311630a383 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Mon, 23 Jun 2025 17:03:11 -0400 Subject: [PATCH 2/2] rescript-language-server: Clean-up with finalAttrs, more platforms, symlink binary 1. rec -> finalAttrs 2. Add platforms (they are marked as broken though) 3. symlink the analysis binary into the directory so that it's not copied --- .../re/rescript-language-server/package.nix | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/pkgs/by-name/re/rescript-language-server/package.nix b/pkgs/by-name/re/rescript-language-server/package.nix index ea7a87e5f530..8e65671dd9e7 100644 --- a/pkgs/by-name/re/rescript-language-server/package.nix +++ b/pkgs/by-name/re/rescript-language-server/package.nix @@ -9,23 +9,25 @@ rescript-editor-analysis, }: let - version = "1.62.0"; - platformDir = if stdenv.hostPlatform.isLinux then "linux" else if stdenv.hostPlatform.isDarwin then "darwin" + else if stdenv.hostPlatform.isFreeBSD then + "freebsd" + else if stdenv.hostPlatform.isWindows then + "win32" else throw "Unsupported system: ${stdenv.system}"; in -buildNpmPackage rec { +buildNpmPackage (finalAttrs: { # These have the same source, and must be the same version. - inherit (rescript-editor-analysis) src; + inherit (rescript-editor-analysis) src version; pname = "rescript-language-server"; - inherit version; - sourceRoot = "${src.name}/server"; + sourceRoot = "${finalAttrs.src.name}/server"; + npmDepsHash = "sha256-Qi41qDJ0WR0QWw7guhuz1imT51SqI7mORGjNbmZWnio"; strictDeps = true; @@ -36,31 +38,40 @@ buildNpmPackage rec { 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 ${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 runHook postBuild ''; + postInstall = '' + DIR="$out/lib/node_modules/@rescript/language-server/analysis_binaries/${platformDir}" + + mkdir -p "$DIR" + ln -s ${lib.getExe rescript-editor-analysis} "$DIR"/rescript-editor-analysis + ''; + nativeInstallCheckInputs = [ versionCheckHook ]; versionCheckProgramArg = "--version"; doInstallCheck = true; - passthru.updateScript = nix-update-script { extraArgs = [ "--version-regex" "([0-9]\.[0-9][0-9]\.[0-9])"]; }; + passthru.updateScript = nix-update-script { + extraArgs = [ + "--version-regex" + "([0-9]+\.[0-9]+\.[0-9]+)" + ]; + }; 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}"; + homepage = "https://github.com/rescript-lang/rescript-vscode/tree/${finalAttrs.version}/server"; + changelog = "https://github.com/rescript-lang/rescript-vscode/releases/tag/${finalAttrs.version}"; mainProgram = "rescript-language-server"; license = lib.licenses.mit; - platforms = lib.platforms.linux ++ lib.platforms.darwin; - maintainers = [ lib.maintainers.RossSmyth ]; + # https://github.com/rescript-lang/rescript-vscode/blob/1.62.0/CONTRIBUTING.md?plain=1#L186 + platforms = with lib.platforms; linux ++ darwin ++ windows ++ freebsd; + maintainers = with lib.maintainers; [ RossSmyth ]; }; -} +})