nixpkgs/pkgs/by-name/so/sonarlint-ls/package.nix
Peder Bergebakken Sundt fcdecc256a
treewide: change ${pname} to string literal (#336172)
* adwaita-icon-theme: change `${pname}` to string literal

* alp: change `${pname}` to string literal

* alsa-oss: change `${pname}` to string literal

* alsa-plugins: change `${pname}` to string literal

* alsa-ucm-conf: change `${pname}` to string literal

* alsa-utils: change `${pname}` to string literal

* anyrun: change `${pname}` to string literal

* assemblyscript: change `${pname}` to string literal

* audiobookshelf: change `${pname}` to string literal

* baobab: change `${pname}` to string literal

* braa: change `${pname}` to string literal

* brill: change `${pname}` to string literal

* centrifugo: change `${pname}` to string literal

* cheese: change `${pname}` to string literal

* cljfmt: change `${pname}` to string literal

* coppwr: change `${pname}` to string literal

* cosmic-edit: change `${pname}` to string literal

* cosmic-files: change `${pname}` to string literal

* cosmic-store: change `${pname}` to string literal

* cosmic-term: change `${pname}` to string literal

* crate2nix: change `${pname}` to string literal

* cups-kyocera-3500-4500: change `${pname}` to string literal

* dbqn: change `${pname}` to string literal

* dconf-editor: change `${pname}` to string literal

* devhelp: change `${pname}` to string literal

* dmarc-report-converter: change `${pname}` to string literal

* engage: change `${pname}` to string literal

* eog: change `${pname}` to string literal

* evolution-data-server-gtk4: change `${pname}` to string literal

* find-billy: change `${pname}` to string literal

* firefly-iii: change `${pname}` to string literal

* fuchsia-cursor: change `${pname}` to string literal

* geary: change `${pname}` to string literal

* ghex: change `${pname}` to string literal

* gitg: change `${pname}` to string literal

* glasskube: change `${pname}` to string literal

* gnome.gnome-autoar: change `${pname}` to string literal

* gnome.gnome-calculator: change `${pname}` to string literal

* gnome.gnome-calendar: change `${pname}` to string literal

* gnome.gnome-common: change `${pname}` to string literal

* gnome.gnome-dictionary: change `${pname}` to string literal

* gnome.gnome-disk-utility: change `${pname}` to string literal

* gnome.gnome-font-viewer: change `${pname}` to string literal

* gnome.gnome-keyring: change `${pname}` to string literal

* gnome.gnome-screenshot: change `${pname}` to string literal

* gnome.gnome-system-monitor: change `${pname}` to string literal

* gnome.seahorse: change `${pname}` to string literal

* gnome.simple-scan: change `${pname}` to string literal

* gnome.sushi: change `${pname}` to string literal

* gnome.totem: change `${pname}` to string literal

* gnome.yelp: change `${pname}` to string literal

* gnome.yelp-xsl: change `${pname}` to string literal

* gnucap-full: change `${pname}` to string literal

* goredo: change `${pname}` to string literal

* guile-semver: change `${pname}` to string literal

* halo: change `${pname}` to string literal

* intiface-central: change `${pname}` to string literal

* intune-portal: change `${pname}` to string literal

* iscc: change `${pname}` to string literal

* jetbrains-toolbox: change `${pname}` to string literal

* jnr-posix: change `${pname}` to string literal

* keymapp: change `${pname}` to string literal

* libation: change `${pname}` to string literal

* libeduvpn-common: change `${pname}` to string literal

* libmamba: change `${pname}` to string literal

* littlefs-fuse: change `${pname}` to string literal

* logseq: change `${pname}` to string literal

* lxgw-wenkai-tc: change `${pname}` to string literal

* microsoft-identity-broker: change `${pname}` to string literal

* minetest-mapserver: change `${pname}` to string literal

* msalsdk-dbusclient: change `${pname}` to string literal

* neverest: change `${pname}` to string literal

* nf-test: change `${pname}` to string literal

* numbat: change `${pname}` to string literal

* pdf2odt: change `${pname}` to string literal

* plemoljp: change `${pname}` to string literal

* plemoljp-hs: change `${pname}` to string literal

* plemoljp-nf: change `${pname}` to string literal

* pocket-updater-utility: change `${pname}` to string literal

* proto: change `${pname}` to string literal

* pw3270: change `${pname}` to string literal

* ratchet: change `${pname}` to string literal

* read-it-later: change `${pname}` to string literal

* redmine: change `${pname}` to string literal

* regina: change `${pname}` to string literal

* regripper: change `${pname}` to string literal

* revolt-desktop: change `${pname}` to string literal

* rs: change `${pname}` to string literal

* signaturepdf: change `${pname}` to string literal

* sonarlint-ls: change `${pname}` to string literal

* srgn: change `${pname}` to string literal

* stackit-cli: change `${pname}` to string literal

* substudy: change `${pname}` to string literal

* swayosd: change `${pname}` to string literal

* synthesia: change `${pname}` to string literal

* tarlz: change `${pname}` to string literal

* termcap: change `${pname}` to string literal

* tinycompress: change `${pname}` to string literal

* tracexec: change `${pname}` to string literal

* treefmt2: change `${pname}` to string literal

* udev-gothic: change `${pname}` to string literal

* udev-gothic-nf: change `${pname}` to string literal

* vvvvvv: change `${pname}` to string literal

* yggdrasil: change `${pname}` to string literal

* zsync: change `${pname}` to string literal
2024-08-20 15:56:55 -07:00

119 lines
3.4 KiB
Nix

{ lib
, fetchFromGitHub
, jre_headless
, maven
, jdk17
, makeWrapper
, writeShellApplication
, runCommand
, sonarlint-ls
, curl
, pcre
, common-updater-scripts
, jq
, gnused
}:
maven.buildMavenPackage rec {
pname = "sonarlint-ls";
version = "3.5.1.75119";
src = fetchFromGitHub {
owner = "SonarSource";
repo = "sonarlint-language-server";
rev = version;
hash = "sha256-6tbuX0wUpqbTyM44e7PqZHL0/XjN8hTFCgfzV+qc1m0=";
};
mvnJdk = jdk17;
manualMvnArtifacts = [
"org.apache.maven.surefire:surefire-junit-platform:3.1.2"
"org.junit.platform:junit-platform-launcher:1.8.2"
];
mvnHash = "sha256-ZhAQtpi0wQP8+QPeYaor2MveY+DZ9RPENb3kITnuWd8=";
buildOffline = true;
# disable node and npm module installation because the need network access
# for the tests.
mvnDepsParameters = "-Dskip.installnodenpm=true -Dskip.npm package";
# disable failing tests which either need network access or are flaky
mvnParameters = lib.escapeShellArgs [
"-Dskip.installnodenpm=true"
"-Dskip.npm"
"-Dtest=!LanguageServerMediumTests,
!LanguageServerWithFoldersMediumTests,
!NotebookMediumTests,
!ConnectedModeMediumTests,
!JavaMediumTests"
];
doCheck = false;
installPhase = ''
runHook preInstall
mkdir -p $out/{bin,share/plugins}
install -Dm644 target/sonarlint-language-server-*.jar \
$out/share/sonarlint-ls.jar
install -Dm644 target/plugins/* \
$out/share/plugins
makeWrapper ${jre_headless}/bin/java $out/bin/sonarlint-ls \
--add-flags "-jar $out/share/sonarlint-ls.jar" \
--add-flags "-stdio" \
--add-flags "-analyzers $(ls -1 $out/share/plugins | tr '\n' ' ')"
runHook postInstall
'';
nativeBuildInputs = [ makeWrapper ];
passthru = {
tests = {
sonarlint-ls-starts-successfully = runCommand "${pname}-test" { } ''
${sonarlint-ls}/bin/sonarlint-ls > $out
cat $out | grep "SonarLint backend started"
'';
};
updateScript =
let
pkgFile = builtins.toString ./package.nix;
in
lib.getExe (writeShellApplication {
name = "update-${pname}";
runtimeInputs = [ curl pcre common-updater-scripts jq gnused ];
text = ''
LATEST_TAG=$(curl https://api.github.com/repos/${src.owner}/${src.repo}/tags | \
jq -r '[.[] | select(.name | test("^[0-9]"))] | sort_by(.name | split(".") |
map(tonumber)) | reverse | .[0].name')
update-source-version sonarlint-ls "$LATEST_TAG"
sed -i '0,/mvnHash *= *"[^"]*"/{s/mvnHash = "[^"]*"/mvnHash = ""/}' ${pkgFile}
echo -e "\nFetching all mvn dependencies to calculate the mvnHash. This may take a while ..."
nix-build -A sonarlint-ls.fetchedMavenDeps 2> sonarlint-ls-stderr.log || true
NEW_MVN_HASH=$(grep "got:" sonarlint-ls-stderr.log | awk '{print ''$2}')
rm sonarlint-ls-stderr.log
# escaping double quotes looks ugly but is needed for variable substitution
# use # instead of / as separator because the sha256 might contain the / character
sed -i "0,/mvnHash *= *\"[^\"]*\"/{s#mvnHash = \"[^\"]*\"#mvnHash = \"$NEW_MVN_HASH\"#}" ${pkgFile}
'';
});
};
meta = {
description = "Sonarlint language server";
mainProgram = "sonarlint-ls";
homepage = "https://github.com/SonarSource/sonarlint-language-server";
license = lib.licenses.lgpl3;
maintainers = with lib.maintainers; [ tricktron ];
};
}