Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 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 jq, 13 unzip, 14 typescript, 15}: 16 17stdenvNoCC.mkDerivation (finalAttrs: { 18 pname = "angular-language-server"; 19 version = "20.1.1"; 20 src = fetchurl { 21 name = "angular-language-server-${finalAttrs.version}.zip"; 22 url = "https://github.com/angular/vscode-ng-language-service/releases/download/v${finalAttrs.version}/ng-template.vsix"; 23 hash = "sha256-fcJXyuGow39uep6Giexft+3a/nnoJSsKdwjtAQKTMj0="; 24 }; 25 26 nativeBuildInputs = [ 27 unzip 28 makeBinaryWrapper 29 ]; 30 31 buildInputs = [ nodejs ]; 32 33 installPhase = '' 34 runHook preInstall 35 install -Dm555 server/bin/ngserver $out/lib/bin/ngserver 36 install -Dm444 server/index.js $out/lib/index.js 37 mkdir -p $out/lib/node_modules 38 cp -r node_modules/* $out/lib/node_modules 39 # do not use vendored typescript 40 rm -rf $out/lib/node_modules/typescript 41 runHook postInstall 42 ''; 43 44 postFixup = '' 45 patchShebangs $out/lib/bin/ngserver $out/lib/index.js $out/lib/node_modules 46 makeWrapper $out/lib/bin/ngserver $out/bin/ngserver \ 47 --prefix PATH : ${lib.makeBinPath [ nodejs ]} \ 48 --add-flags "--tsProbeLocations ${typescript}/lib/node_modules/typescript --ngProbeLocations $out/lib/node_modules" 49 ''; 50 51 passthru = { 52 tests = { 53 start-ok = runCommand "${finalAttrs.pname}-test" { } '' 54 ${lib.getExe angular-language-server} --stdio --help &> $out 55 cat $out | grep "Angular Language Service that implements the Language Server Protocol (LSP)" 56 ''; 57 }; 58 59 updateScript = lib.getExe (writeShellApplication { 60 name = "update-angular-language-server"; 61 runtimeInputs = [ 62 curl 63 common-updater-scripts 64 jq 65 ]; 66 text = '' 67 if [ -z "''${GITHUB_TOKEN:-}" ]; then 68 echo "no GITHUB_TOKEN provided - you could meet API request limiting" >&2 69 fi 70 71 LATEST_VERSION=$(curl -H "Accept: application/vnd.github+json" \ 72 ''${GITHUB_TOKEN:+-H "Authorization: bearer $GITHUB_TOKEN"} \ 73 -Lsf https://api.github.com/repos/angular/vscode-ng-language-service/releases/latest | \ 74 jq -r .tag_name | cut -c 2-) 75 update-source-version angular-language-server "$LATEST_VERSION" 76 ''; 77 }); 78 }; 79 80 meta = { 81 description = "LSP for angular completions, AOT diagnostic, quick info and go to definitions"; 82 homepage = "https://github.com/angular/vscode-ng-language-service"; 83 sourceProvenance = with lib.sourceTypes; [ binaryBytecode ]; 84 changelog = "https://github.com/angular/vscode-ng-language-service/blob/${finalAttrs.version}/CHANGELOG.md"; 85 license = lib.licenses.mit; 86 platforms = lib.platforms.unix; 87 mainProgram = "ngserver"; 88 maintainers = with lib.maintainers; [ tricktron ]; 89 }; 90})