{ lib, maven, jdk21, fetchFromGitHub, writeShellScript, }: let jdk = jdk21; in maven.buildMavenPackage rec { pname = "jls"; version = "0-unstable-2025-11-15"; src = fetchFromGitHub { owner = "idelice"; repo = "jls"; rev = "82d341b55258113c6112e673518f92d84d1f7dd7"; hash = "sha256-MCm0sYoHgSNHJgKWAXw67Qct4derqpy0uD+PtzNyDhc="; }; mvnJdk = jdk; mvnHash = "sha256-x1Je1mcvovs4brwNaROKOlnZ4YvqrZicuCCcGSCIFP8="; mvnParameters = "-DskipTests"; # The configure script just sets up git hooks, not needed for build postPatch = '' rm -f configure ''; installPhase = let jvmFlags = lib.concatStringsSep " " [ "--add-modules jdk.jdeps" "--add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED" "--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED" "--add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED" "--add-exports jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED" "--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED" "--add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED" "--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED" "--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED" "--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED" "--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED" "--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED" "--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" "--add-opens jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED" "--add-opens jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED" "--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED" "--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED" "--add-opens jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED" "--add-opens jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED" "--add-opens jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED" "--add-opens jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED" "--add-opens jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED" "--add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" "--add-opens jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED" ]; in '' runHook preInstall mkdir -p $out/share/jls $out/bin cp dist/classpath/*.jar $out/share/jls/ cat > $out/bin/jls <<'WRAPPER' #!/bin/sh exec @java@ ${jvmFlags} -classpath "@classpath@" org.javacs.Main "$@" WRAPPER chmod +x $out/bin/jls substituteInPlace $out/bin/jls \ --replace-fail "@java@" "${jdk}/bin/java" \ --replace-fail "@classpath@" "$out/share/jls/*" runHook postInstall ''; meta = { description = "Java Language Server using the Java compiler API"; homepage = "https://github.com/idelice/jls"; license = lib.licenses.mit; mainProgram = "jls"; platforms = lib.platforms.unix; }; }