ripasso-cursive: cosmetic changes (#361736)
[NixPkgs.git] / pkgs / by-name / an / angular-language-server / package.nix
blob0cf1776ee82ef0eacdb26e250d3d103c1a9272e0
2   lib,
3   stdenvNoCC,
4   fetchurl,
5   nodejs,
6   makeBinaryWrapper,
7   runCommand,
8   angular-language-server,
9   writeShellApplication,
10   curl,
11   common-updater-scripts,
12   unzip,
15 stdenvNoCC.mkDerivation (finalAttrs: {
16   pname = "angular-language-server";
17   version = "18.2.0";
18   src = fetchurl {
19     name = "angular-language-server-${finalAttrs.version}.zip";
20     url = "https://github.com/angular/vscode-ng-language-service/releases/download/v${finalAttrs.version}/ng-template.vsix";
21     hash = "sha256-rl04nqSSBMjZfPW8Y+UtFLFLDFd5FSxJs3S937mhDWE=";
22   };
24   nativeBuildInputs = [
25     unzip
26     makeBinaryWrapper
27   ];
29   buildInputs = [ nodejs ];
31   installPhase = ''
32     runHook preInstall
33     install -Dm755 server/bin/ngserver $out/lib/bin/ngserver
34     install -Dm755 server/index.js $out/lib/index.js
35     cp -r node_modules $out/lib/node_modules
36     runHook postInstall
37   '';
39   postFixup = ''
40     patchShebangs $out/lib/bin/ngserver $out/lib/index.js $out/lib/node_modules
41     makeWrapper $out/lib/bin/ngserver $out/bin/ngserver \
42       --prefix PATH : ${lib.makeBinPath [ nodejs ]} \
43       --add-flags "--tsProbeLocations $out/lib/node_modules --ngProbeLocations $out/lib/node_modules"
44   '';
46   passthru = {
47     tests = {
48       start-ok = runCommand "${finalAttrs.pname}-test" { } ''
49         ${lib.getExe angular-language-server} --stdio --help &> $out
50         cat $out | grep "Angular Language Service that implements the Language Server Protocol (LSP)"
51       '';
52     };
54     updateScript = lib.getExe (writeShellApplication {
55       name = "update-angular-language-server";
56       runtimeInputs = [
57         curl
58         common-updater-scripts
59       ];
60       text = ''
61         if [ -z "''${GITHUB_TOKEN:-}" ]; then
62             echo "no GITHUB_TOKEN provided - you could meet API request limiting" >&2
63         fi
65         LATEST_VERSION=$(curl -H "Accept: application/vnd.github+json" \
66             ''${GITHUB_TOKEN:+-H "Authorization: bearer $GITHUB_TOKEN"} \
67           -Lsf https://api.github.com/repos/angular/vscode-ng-language-service/releases/latest | \
68           jq -r .tag_name | cut -c 2-)
69         update-source-version angular-language-server "$LATEST_VERSION"
70       '';
71     });
72   };
74   meta = {
75     description = "LSP for angular completions, AOT diagnostic, quick info and go to definitions";
76     homepage = "https://github.com/angular/vscode-ng-language-service";
77     sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
78     changelog = "https://github.com/angular/vscode-ng-language-service/blob/${finalAttrs.version}/CHANGELOG.md";
79     license = lib.licenses.mit;
80     platforms = lib.platforms.unix;
81     mainProgram = "ngserver";
82     maintainers = with lib.maintainers; [ tricktron ];
83   };