7 , writeShellApplication
12 , common-updater-scripts
17 maven.buildMavenPackage rec {
18 pname = "sonarlint-ls";
19 version = "3.5.1.75119";
21 src = fetchFromGitHub {
22 owner = "SonarSource";
23 repo = "sonarlint-language-server";
25 hash = "sha256-6tbuX0wUpqbTyM44e7PqZHL0/XjN8hTFCgfzV+qc1m0=";
29 manualMvnArtifacts = [
30 "org.apache.maven.surefire:surefire-junit-platform:3.1.2"
31 "org.junit.platform:junit-platform-launcher:1.8.2"
34 mvnHash = "sha256-ZhAQtpi0wQP8+QPeYaor2MveY+DZ9RPENb3kITnuWd8=";
39 # disable node and npm module installation because the need network access
41 mvnDepsParameters = "-Dskip.installnodenpm=true -Dskip.npm package";
43 # disable failing tests which either need network access or are flaky
44 mvnParameters = lib.escapeShellArgs [
45 "-Dskip.installnodenpm=true"
47 "-Dtest=!LanguageServerMediumTests,
48 !LanguageServerWithFoldersMediumTests,
50 !ConnectedModeMediumTests,
59 mkdir -p $out/{bin,share/plugins}
60 install -Dm644 target/sonarlint-language-server-*.jar \
61 $out/share/sonarlint-ls.jar
62 install -Dm644 target/plugins/* \
66 makeWrapper ${jre_headless}/bin/java $out/bin/sonarlint-ls \
67 --add-flags "-jar $out/share/sonarlint-ls.jar" \
68 --add-flags "-stdio" \
69 --add-flags "-analyzers $(ls -1 $out/share/plugins | tr '\n' ' ')"
74 nativeBuildInputs = [ makeWrapper ];
78 sonarlint-ls-starts-successfully = runCommand "${pname}-test" { } ''
79 ${sonarlint-ls}/bin/sonarlint-ls > $out
80 cat $out | grep "SonarLint backend started"
86 pkgFile = builtins.toString ./package.nix;
88 lib.getExe (writeShellApplication {
89 name = "update-${pname}";
90 runtimeInputs = [ curl pcre common-updater-scripts jq gnused ];
92 LATEST_TAG=$(curl https://api.github.com/repos/${src.owner}/${src.repo}/tags | \
93 jq -r '[.[] | select(.name | test("^[0-9]"))] | sort_by(.name | split(".") |
94 map(tonumber)) | reverse | .[0].name')
95 update-source-version sonarlint-ls "$LATEST_TAG"
96 sed -i '0,/mvnHash *= *"[^"]*"/{s/mvnHash = "[^"]*"/mvnHash = ""/}' ${pkgFile}
98 echo -e "\nFetching all mvn dependencies to calculate the mvnHash. This may take a while ..."
99 nix-build -A sonarlint-ls.fetchedMavenDeps 2> sonarlint-ls-stderr.log || true
101 NEW_MVN_HASH=$(grep "got:" sonarlint-ls-stderr.log | awk '{print ''$2}')
102 rm sonarlint-ls-stderr.log
103 # escaping double quotes looks ugly but is needed for variable substitution
104 # use # instead of / as separator because the sha256 might contain the / character
105 sed -i "0,/mvnHash *= *\"[^\"]*\"/{s#mvnHash = \"[^\"]*\"#mvnHash = \"$NEW_MVN_HASH\"#}" ${pkgFile}
111 description = "Sonarlint language server";
112 mainProgram = "sonarlint-ls";
113 homepage = "https://github.com/SonarSource/sonarlint-language-server";
114 license = lib.licenses.lgpl3;
115 maintainers = with lib.maintainers; [ tricktron ];