Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

angular-language-server-bin: init at 18.2.0 #350257

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions pkgs/by-name/an/angular-language-server-bin/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
lib,
stdenvNoCC,
fetchurl,
nodejs,
makeBinaryWrapper,
runCommand,
angular-language-server-bin,
writeShellApplication,
curl,
common-updater-scripts,
jq,
unzip,
}:

let
owner = "angular";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just hardcore those. They will likely never ever change.

repo = "vscode-ng-language-service";
in
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "angular-language-server-bin";
version = "18.2.0";
src = fetchurl {
name = "${finalAttrs.pname}-${finalAttrs.version}.zip";
url = "https://github.com/${owner}/${repo}/releases/download/v${finalAttrs.version}/ng-template.vsix";
hash = "sha256-rl04nqSSBMjZfPW8Y+UtFLFLDFd5FSxJs3S937mhDWE=";
};

nativeBuildInputs = [
unzip
makeBinaryWrapper
];

buildInputs = [ nodejs ];

installPhase = ''
runHook preInstall
install -Dm755 server/bin/ngserver $out/bin/ngserver
install -Dm755 server/index.js $out/index.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we place those not at /?

cp -r node_modules $out/node_modules
runHook postInstall
'';

postFixup = ''
patchShebangs $out/bin/ngserver $out/index.js $out/node_modules
wrapProgram $out/bin/ngserver \
--prefix PATH : ${lib.makeBinPath [ nodejs ]} \
--add-flags "--tsProbeLocations $out/node_modules --ngProbeLocations $out/node_modules"
'';

passthru = {
tests = {
start-ok = runCommand "${finalAttrs.pname}-test" { } ''
${angular-language-server-bin}/bin/ngserver --stdio --help &> $out
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use lib.getExe here and grep in one go

cat $out | grep "Angular Language Service that implements the Language Server Protocol (LSP)"
'';
};

updateScript = lib.getExe (writeShellApplication {
name = "update-${finalAttrs.pname}";
runtimeInputs = [
curl
common-updater-scripts
jq
];
text = ''
LATEST_VERSION=$(curl -H "Accept: application/vnd.github+json" \
-Ls https://api.github.com/repos/${owner}/${repo}/releases/latest | \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should optionally take a GITHUB_TOKEN

jq -r .tag_name | cut -c 2-)
update-source-version ${finalAttrs.pname} "$LATEST_VERSION"
'';
});
};

meta = {
description = "LSP for angular completions, AOT diagnostic, quick info and go to definitions";
homepage = "https://github.com/angular/vscode-ng-language-service";
changelog = "https://github.com/angular/vscode-ng-language-service/blob/${finalAttrs.version}/CHANGELOG.md";
license = lib.licenses.mit;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we have an appropriate sourceProvenance for prebuild js things.

mainProgram = "ngserver";
maintainers = with lib.maintainers; [ tricktron ];
};
})