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..8e65671dd9e7 100644 --- a/pkgs/by-name/re/rescript-language-server/package.nix +++ b/pkgs/by-name/re/rescript-language-server/package.nix @@ -9,29 +9,26 @@ 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 version; pname = "rescript-language-server"; - inherit version; - src = fetchFromGitHub { - owner = "rescript-lang"; - repo = "rescript-vscode"; - tag = version; - hash = "sha256-Tox5Qq0Kpqikac90sQww2cGr9RHlXnVy7GMnRA18CoA="; - }; + sourceRoot = "${finalAttrs.src.name}/server"; - sourceRoot = "${src.name}/server"; - npmDepsHash = "sha256-Qi41qDJ0WR0QWw7guhuz1imT51SqI7mORGjNbmZWnio="; + npmDepsHash = "sha256-Qi41qDJ0WR0QWw7guhuz1imT51SqI7mORGjNbmZWnio"; strictDeps = true; nativeBuildInputs = [ esbuild ]; @@ -41,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 { }; + 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 ]; }; -} +})