nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 python3,
6 jdk,
7}:
8
9let
10 timestamp = "202601131729";
11in
12stdenv.mkDerivation (finalAttrs: {
13 pname = "jdt-language-server";
14 version = "1.55.0";
15
16 src = fetchurl {
17 url = "https://download.eclipse.org/jdtls/milestones/${finalAttrs.version}/jdt-language-server-${finalAttrs.version}-${timestamp}.tar.gz";
18 hash = "sha256-kGJ8nwNwTbtATzdlFiXQdRwHirdTQkYCPVOtzqFBG5E=";
19 };
20
21 sourceRoot = ".";
22
23 buildInputs = [
24 # Used for the included wrapper
25 python3
26 ];
27
28 postPatch = ''
29 # We store the plugins, config, and features folder in different locations
30 # than in the original package. In addition, hard-code the path to the jdk
31 # in the wrapper, instead of searching for it in PATH at runtime.
32 substituteInPlace bin/jdtls.py \
33 --replace-fail "jdtls_base_path = Path(__file__).parent.parent" "jdtls_base_path = Path(\"$out/share/java/jdtls/\")" \
34 --replace-fail "java_executable = get_java_executable(known_args)" "java_executable = '${lib.getExe jdk}'"
35 '';
36
37 installPhase =
38 let
39 # The application ships with different config directories for each platform.
40 # Note the application come with ARM variants as well, although the
41 # current included wrapper doesn't use them.
42 configDir = if stdenv.hostPlatform.isDarwin then "config_mac" else "config_linux";
43 in
44 ''
45 runHook preInstall
46
47 install -Dm444 -t $out/share/java/jdtls/plugins/ plugins/*
48 install -Dm444 -t $out/share/java/jdtls/features/ features/*
49 install -Dm444 -t $out/share/java/jdtls/${configDir} ${configDir}/*
50 install -Dm555 -t $out/bin bin/jdtls
51 install -Dm444 -t $out/bin bin/jdtls.py
52
53 runHook postInstall
54 '';
55
56 passthru.updateScript = ./update.sh;
57
58 meta = {
59 homepage = "https://github.com/eclipse/eclipse.jdt.ls";
60 description = "Java language server";
61 sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
62 license = lib.licenses.epl20;
63 maintainers = with lib.maintainers; [
64 matt-snider
65 wenjinnn
66 ];
67 platforms = lib.platforms.all;
68 mainProgram = "jdtls";
69 };
70})