|
| 1 | +{ |
| 2 | + stdenv, |
| 3 | + lib, |
| 4 | + fetchFromGitHub, |
| 5 | + nodejs_22, |
| 6 | + gitMinimal, |
| 7 | + pnpm_8, |
| 8 | +}: |
| 9 | + |
| 10 | +stdenv.mkDerivation (finalAttrs: { |
| 11 | + pname = "vtsls"; |
| 12 | + version = "0.2.6"; |
| 13 | + |
| 14 | + src = fetchFromGitHub { |
| 15 | + owner = "yioneko"; |
| 16 | + repo = "vtsls"; |
| 17 | + rev = "server-v${finalAttrs.version}"; |
| 18 | + hash = "sha256-HCi9WLh4IEfhgkQNUVk6IGkQfYagg805Rix78zG6xt0="; |
| 19 | + fetchSubmodules = true; |
| 20 | + }; |
| 21 | + |
| 22 | + nativeBuildInputs = [ |
| 23 | + nodejs_22 |
| 24 | + # patches are applied with git during build |
| 25 | + gitMinimal |
| 26 | + pnpm_8.configHook |
| 27 | + ]; |
| 28 | + |
| 29 | + buildInputs = [ nodejs_22 ]; |
| 30 | + |
| 31 | + pnpmWorkspaces = [ "@vtsls/language-server" ]; |
| 32 | + |
| 33 | + pnpmDeps = pnpm_8.fetchDeps { |
| 34 | + inherit (finalAttrs) |
| 35 | + pnpmWorkspaces |
| 36 | + pname |
| 37 | + src |
| 38 | + version |
| 39 | + ; |
| 40 | + hash = "sha256-4XxQ0Z2atTBItrD9iY7q5rJaCmb1EeDBvQ5+L3ceRXI="; |
| 41 | + }; |
| 42 | + |
| 43 | + # Patches to get submodule sha from file instead of 'git submodule status' |
| 44 | + patches = [ ./vtsls-build-patch.patch ]; |
| 45 | + |
| 46 | + # Skips manual confirmations during build |
| 47 | + CI = true; |
| 48 | + |
| 49 | + buildPhase = '' |
| 50 | + runHook preBuild |
| 51 | +
|
| 52 | + # During build vtsls needs a working git installation. |
| 53 | + git config --global user.name nixbld |
| 54 | + git config --global user.email [email protected] |
| 55 | +
|
| 56 | + # during build this sha is used as a marker to skip applying patches and |
| 57 | + # copying files, which doesn't matter in this case |
| 58 | + echo "dummysha" > ./packages/service/HEAD |
| 59 | +
|
| 60 | + # Requires a git repository during build |
| 61 | + git init packages/service/vscode |
| 62 | +
|
| 63 | + # Depends on the @vtsls/language-service workspace |
| 64 | + # '--workspace-concurrency=1' helps debug failing builds. |
| 65 | + pnpm --filter "@vtsls/language-server..." build |
| 66 | +
|
| 67 | + # These trash deterministic builds. During build the whole directory is |
| 68 | + # copied to another path. |
| 69 | + rm -rf packages/service/vscode/.git |
| 70 | + rm -rf packages/service/src/typescript-language-features/.git |
| 71 | +
|
| 72 | + runHook postBuild |
| 73 | + ''; |
| 74 | + |
| 75 | + installPhase = '' |
| 76 | + runHook preInstall |
| 77 | +
|
| 78 | + mkdir -p $out/{bin,lib/vtsls-language-server} |
| 79 | + cp -r {packages,node_modules} $out/lib/vtsls-language-server |
| 80 | + ln -s $out/lib/vtsls-language-server/packages/server/bin/vtsls.js $out/bin/vtsls |
| 81 | +
|
| 82 | + runHook postInstall |
| 83 | + ''; |
| 84 | + |
| 85 | + meta = { |
| 86 | + description = "LSP wrapper for typescript extension of vscode."; |
| 87 | + homepage = "https://github.com/yioneko/vtsls"; |
| 88 | + license = lib.licenses.mit; |
| 89 | + maintainers = with lib.maintainers; [ kuglimon ]; |
| 90 | + mainProgram = "vtsls"; |
| 91 | + platforms = lib.platforms.all; |
| 92 | + }; |
| 93 | +}) |
0 commit comments