From af0589b0e61fd316443b92860df1e87dee2ffc1f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=A9clairevoyant?=
 <848000+eclairevoyant@users.noreply.github.com>
Date: Wed, 24 Jan 2024 11:46:22 -0500
Subject: [PATCH 1/2] jdt-language-server: move to `pkgs/by-name`

---
 .../default.nix => by-name/jd/jdt-language-server/package.nix}  | 0
 pkgs/top-level/all-packages.nix                                 | 2 --
 2 files changed, 2 deletions(-)
 rename pkgs/{development/tools/language-servers/jdt-language-server/default.nix => by-name/jd/jdt-language-server/package.nix} (100%)

diff --git a/pkgs/development/tools/language-servers/jdt-language-server/default.nix b/pkgs/by-name/jd/jdt-language-server/package.nix
similarity index 100%
rename from pkgs/development/tools/language-servers/jdt-language-server/default.nix
rename to pkgs/by-name/jd/jdt-language-server/package.nix
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 70421bfffb60..4fa58572363f 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -18318,8 +18318,6 @@ with pkgs;
 
   javascript-typescript-langserver = callPackage ../development/tools/language-servers/javascript-typescript-langserver { };
 
-  jdt-language-server = callPackage ../development/tools/language-servers/jdt-language-server { };
-
   jsonnet-language-server = callPackage ../development/tools/language-servers/jsonnet-language-server { };
 
   kotlin-language-server = callPackage ../development/tools/language-servers/kotlin-language-server { };

From 6b19a1f3fe225c495bceeba8d2b773e3e2442e0c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=A9clairevoyant?=
 <848000+eclairevoyant@users.noreply.github.com>
Date: Thu, 11 Jan 2024 05:27:51 -0500
Subject: [PATCH 2/2] jdt-language-server: set `passthru.updateScript`

---
 .../jd/jdt-language-server/package.nix        |  2 ++
 pkgs/by-name/jd/jdt-language-server/update.sh | 21 +++++++++++++++++++
 2 files changed, 23 insertions(+)
 create mode 100644 pkgs/by-name/jd/jdt-language-server/update.sh

diff --git a/pkgs/by-name/jd/jdt-language-server/package.nix b/pkgs/by-name/jd/jdt-language-server/package.nix
index 626db26e89b1..2e25aa24f789 100644
--- a/pkgs/by-name/jd/jdt-language-server/package.nix
+++ b/pkgs/by-name/jd/jdt-language-server/package.nix
@@ -48,6 +48,8 @@ stdenv.mkDerivation (finalAttrs: {
       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";
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 000000000000..b482db22ee05
--- /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\"|" \