summaryrefslogtreecommitdiffstats
path: root/flake/pkgs/by-name/stimulus-language-server/package.nix
blob: 61e889d3b8c2eafe832ef6e2754c854c0ab7a658 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{
  lib,
  stdenvNoCC,
  fetchFromGitHub,
  fetchYarnDeps,
  fetchurl,
  yarnConfigHook,
  yarnBuildHook,
  yarnInstallHook,
  nodejs,
  runCommand,
  patch,
  nix-update-script,
}: let
  version = "1.1.0";

  upstream = fetchFromGitHub {
    owner = "marcoroth";
    repo = "stimulus-lsp";
    tag = "v${version}";
    hash = "sha256-QAXQKZoFvqhnbAIi9fnJ7pV8fXah0NjwxdrqKB5e5Vw=";
  };

  # `fetchYarnDeps` doesn't support tarballs so we need to patch this manually
  stimulusTarball = fetchurl {
    url = "https://github.com/hotwired/dev-builds/archive/refs/tags/@hotwired/stimulus/8cbca6d.tar.gz";
    hash = "sha256-2iRIiwXmdcSw7y3CQNIPt6duwZuVvDvdU/FEdqcnzW4=";
  };

  src = runCommand "stimulus-lsp-server-patched" {nativeBuildInputs = [patch];} ''
    cp -r ${upstream}/server $out
    chmod -R +w $out
    cp '${stimulusTarball}' $out/hotwired-stimulus.tar.gz
    patch -d $out -p1 < '${./0001-use-local-hotwired.patch}'
    patch -d $out -p1 < '${./0002-add-types-node.patch}'
  '';
in
  stdenvNoCC.mkDerivation {
    pname = "stimulus-language-server";
    inherit version src;

    offlineCache = fetchYarnDeps {
      yarnLock = "${src}/yarn.lock";
      hash = "sha256-UvojI/Ow602Q+iiwRpSgxm4DV0IJ0sURicdgghmpBsU=";
    };

    nativeBuildInputs = [
      yarnConfigHook
      yarnBuildHook
      yarnInstallHook
      nodejs
    ];

    passthru.updateScript = nix-update-script {};

    meta = {
      description = "Intelligent Stimulus tooling";
      homepage = "https://hotwire.io/ecosystem/tooling/stimulus-lsp";
      changelog = "https://github.com/marcoroth/stimulus-lsp/releases/tag/v${version}";
      license = lib.licenses.mit;
      mainProgram = "stimulus-language-server";
    };
  }