about summary refs log tree commit diff
path: root/pkgs/development/tools/language-servers
diff options
context:
space:
mode:
authorhuantian <davidtianli@gmail.com>2024-01-06 19:30:02 -0800
committerhuantian <davidtianli@gmail.com>2024-01-22 14:28:02 -0800
commit302dc9deb2f53178e384d6652ac09717699ecf95 (patch)
treee1d662de691a4981aa142a8f740cbd9abd0a46ef /pkgs/development/tools/language-servers
parent0d308a02a6a38e40ed7921b171babeaa285ad3e3 (diff)
jdt-language-server: 1.26.0 -> 1.31.0, use upstream wrapper
Co-authored-by: kirillrdy <kirillrdy@gmail.com>
Diffstat (limited to 'pkgs/development/tools/language-servers')
-rw-r--r--pkgs/development/tools/language-servers/jdt-language-server/default.nix110
1 files changed, 34 insertions, 76 deletions
diff --git a/pkgs/development/tools/language-servers/jdt-language-server/default.nix b/pkgs/development/tools/language-servers/jdt-language-server/default.nix
index 3de28f65145f5..626db26e89b1b 100644
--- a/pkgs/development/tools/language-servers/jdt-language-server/default.nix
+++ b/pkgs/development/tools/language-servers/jdt-language-server/default.nix
@@ -1,102 +1,60 @@
 { lib
 , stdenv
 , fetchurl
-, makeWrapper
+, python3
 , jdk
 }:
 
-stdenv.mkDerivation rec {
+let
+  timestamp = "202401111522";
+in
+stdenv.mkDerivation (finalAttrs: {
   pname = "jdt-language-server";
-  version = "1.26.0";
-  timestamp = "202307271613";
+  version = "1.31.0";
 
   src = fetchurl {
-    url = "https://download.eclipse.org/jdtls/milestones/${version}/jdt-language-server-${version}-${timestamp}.tar.gz";
-    sha256 = "sha256-ul/l7jsqg5UofiSu8gzm4Xg0z46HcRfmyqysamiKbFM=";
+    url = "https://download.eclipse.org/jdtls/milestones/${finalAttrs.version}/jdt-language-server-${finalAttrs.version}-${timestamp}.tar.gz";
+    hash = "sha256-bCX2LQt00d2SqxmvuvvlBB6wbCuFPqtX9/Qv5v6wH3w=";
   };
 
   sourceRoot = ".";
 
   buildInputs = [
-    jdk
+    # Used for the included wrapper
+    python3
   ];
 
-  nativeBuildInputs = [
-    makeWrapper
-  ];
+  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 config directories for linux and mac
+      # 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
-      ''
-      # Copy jars
-      install -D -t $out/share/java/plugins/ plugins/*.jar
-
-      # Copy config directories for linux and mac
-      install -Dm 444 -t $out/share/config ${configDir}/*
-
-      # Get latest version of launcher jar
-      # e.g. org.eclipse.equinox.launcher_1.5.800.v20200727-1323.jar
-      launcher="$(ls $out/share/java/plugins/org.eclipse.equinox.launcher_* | sort -V | tail -n1)"
-
-      # The wrapper script will create a directory in the user's cache, copy in the config
-      # files since this dir can't be read-only, and by default use this as the runtime dir.
-      #
-      # The following options are required as per the upstream documentation:
-      #
-      #   -Declipse.application=org.eclipse.jdt.ls.core.id1
-      #   -Dosgi.bundles.defaultStartLevel=4
-      #   -Declipse.product=org.eclipse.jdt.ls.core.product
-      #   --add-modules=ALL-SYSTEM
-      #   --add-opens java.base/java.util=ALL-UNNAMED
-      #   --add-opens java.base/java.lang=ALL-UNNAMED
-      #
-      # The following options configure the server to run without writing logs to the nix store:
-      #
-      #   -Dosgi.sharedConfiguration.area.readOnly=true
-      #   -Dosgi.checkConfiguration=true
-      #   -Dosgi.configuration.cascaded=true
-      #   -Dosgi.sharedConfiguration.area=$out/share/config
-      #
-      # Other options which the caller may change:
-      #
-      #   -Dlog.level:
-      #     Log level.
-      #     This can be overidden by setting JAVA_OPTS.
-      #
-      # The caller must specify the following:
-      #
-      #   -data:
-      #     The application stores runtime data here. We set this to <cache-dir>/$PWD
-      #     so that projects don't collide with each other.
-      #     This can be overidden by specifying -configuration to the wrapper.
-      #
-      # Java options, such as -Xms and Xmx can be specified by setting JAVA_OPTS.
-      #
-      makeWrapper ${jdk}/bin/java $out/bin/jdt-language-server \
-        --add-flags "-Declipse.application=org.eclipse.jdt.ls.core.id1" \
-        --add-flags "-Dosgi.bundles.defaultStartLevel=4" \
-        --add-flags "-Declipse.product=org.eclipse.jdt.ls.core.product" \
-        --add-flags "-Dosgi.sharedConfiguration.area=$out/share/config" \
-        --add-flags "-Dosgi.sharedConfiguration.area.readOnly=true" \
-        --add-flags "-Dosgi.checkConfiguration=true" \
-        --add-flags "-Dosgi.configuration.cascaded=true" \
-        --add-flags "-Dlog.level=ALL" \
-        --add-flags "\$JAVA_OPTS" \
-        --add-flags "-jar $launcher" \
-        --add-flags "--add-modules=ALL-SYSTEM" \
-        --add-flags "--add-opens java.base/java.util=ALL-UNNAMED" \
-        --add-flags "--add-opens java.base/java.lang=ALL-UNNAMED"
+    ''
+      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
     '';
 
-  meta = with lib; {
+  meta = {
     homepage = "https://github.com/eclipse/eclipse.jdt.ls";
     description = "Java language server";
-    sourceProvenance = with sourceTypes; [ binaryBytecode ];
-    license = licenses.epl20;
-    maintainers = with maintainers; [ matt-snider ];
-    platforms = platforms.all;
+    sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
+    license = lib.licenses.epl20;
+    maintainers = with lib.maintainers; [ matt-snider ];
+    platforms = lib.platforms.all;
+    mainProgram = "jdtls";
   };
-}
+})