Commit ef92c406 authored by Ross Smyth's avatar Ross Smyth
Browse files

rescript-language-server: init at 1.62.0

parent b8700931
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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}
+71 −0
Original line number Diff line number Diff line
{
  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 ];
  };
}
+5 −0
Original line number Diff line number Diff line
@@ -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 { };