diff options
Diffstat (limited to 'pkgs/by-name')
-rw-r--r-- | pkgs/by-name/jd/jdt-language-server/package.nix | 62 | ||||
-rw-r--r-- | pkgs/by-name/jd/jdt-language-server/update.sh | 21 |
2 files changed, 83 insertions, 0 deletions
diff --git a/pkgs/by-name/jd/jdt-language-server/package.nix b/pkgs/by-name/jd/jdt-language-server/package.nix new file mode 100644 index 0000000000000..2e25aa24f7898 --- /dev/null +++ b/pkgs/by-name/jd/jdt-language-server/package.nix @@ -0,0 +1,62 @@ +{ lib +, stdenv +, fetchurl +, python3 +, jdk +}: + +let + timestamp = "202401111522"; +in +stdenv.mkDerivation (finalAttrs: { + pname = "jdt-language-server"; + version = "1.31.0"; + + src = fetchurl { + url = "https://download.eclipse.org/jdtls/milestones/${finalAttrs.version}/jdt-language-server-${finalAttrs.version}-${timestamp}.tar.gz"; + hash = "sha256-bCX2LQt00d2SqxmvuvvlBB6wbCuFPqtX9/Qv5v6wH3w="; + }; + + sourceRoot = "."; + + buildInputs = [ + # Used for the included wrapper + python3 + ]; + + postPatch = '' + # We store the plugins, config, and features folder in different locations + # than in the original package. In addition, hard-code the path to the jdk + # in the wrapper, instead of searching for it in PATH at runtime. + substituteInPlace bin/jdtls.py \ + --replace "jdtls_base_path = Path(__file__).parent.parent" "jdtls_base_path = Path(\"$out/share/java/jdtls/\")" \ + --replace "java_executable = get_java_executable(known_args.validate_java_version)" "java_executable = '${lib.getExe jdk}'" + ''; + + installPhase = + let + # The application ships with different config directories for each platform. + # Note the application come with ARM variants as well, although the + # current included wrapper doesn't use them. + configDir = if stdenv.isDarwin then "config_mac" else "config_linux"; + in + '' + install -Dm444 -t $out/share/java/jdtls/plugins/ plugins/* + install -Dm444 -t $out/share/java/jdtls/features/ features/* + install -Dm444 -t $out/share/java/jdtls/${configDir} ${configDir}/* + install -Dm555 -t $out/bin bin/jdtls + install -Dm444 -t $out/bin bin/jdtls.py + ''; + + passthru.updateScript = ./update.sh; + + meta = { + homepage = "https://github.com/eclipse/eclipse.jdt.ls"; + description = "Java language server"; + sourceProvenance = with lib.sourceTypes; [ binaryBytecode ]; + license = lib.licenses.epl20; + maintainers = with lib.maintainers; [ matt-snider ]; + platforms = lib.platforms.all; + mainProgram = "jdtls"; + }; +}) diff --git a/pkgs/by-name/jd/jdt-language-server/update.sh b/pkgs/by-name/jd/jdt-language-server/update.sh new file mode 100644 index 0000000000000..b482db22ee056 --- /dev/null +++ b/pkgs/by-name/jd/jdt-language-server/update.sh @@ -0,0 +1,21 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i bash --pure -p curl cacert libxml2 yq nix jq + +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")" +DRV_DIR="$PWD" + +# scrape the downloads page for release info +newver=$(curl -s 'https://download.eclipse.org/jdtls/milestones/' | xmllint --html - --xmlout 2>/dev/null | xq --raw-output '.html.body.main.div.div.div[0].div.table.tr | max_by(.td[3]).td[1].a.["#text"]') + +prefix="https://download.eclipse.org/jdtls/milestones/$newver" + +filename=$(curl -s "$prefix/latest.txt") +newtimestamp=$(echo $filename | sed "s|^.*-$newver-||;s|\.tar\.gz$||") +newhash="$(nix-hash --to-sri --type sha256 $(nix-prefetch-url "$prefix/$filename"))"; + +sed -i default.nix \ + -e "/^ version =/ s|\".*\"|\"$newver\"|" \ + -e "/^ timestamp =/ s|\".*\"|\"$newtimestamp\"|" \ + -e "/^ hash =/ s|\".*\"|\"$newhash\"|" \ |