nixpkgs/pkgs/by-name/jd/jdt-language-server/package.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

67 lines
2.1 KiB
Nix

{ lib
, stdenv
, fetchurl
, python3
, jdk
}:
let
timestamp = "202408291433";
in
stdenv.mkDerivation (finalAttrs: {
pname = "jdt-language-server";
version = "1.39.0";
src = fetchurl {
url = "https://download.eclipse.org/jdtls/milestones/${finalAttrs.version}/jdt-language-server-${finalAttrs.version}-${timestamp}.tar.gz";
hash = "sha256-8EbY8Il05udz8u1HQmbqsJiJxkWfJmNXn4t9SXvTRyk=";
};
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-fail "jdtls_base_path = Path(__file__).parent.parent" "jdtls_base_path = Path(\"$out/share/java/jdtls/\")" \
--replace-fail "java_executable = get_java_executable(known_args)" "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.hostPlatform.isDarwin then "config_mac" else "config_linux";
in
''
runHook preInstall
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
runHook postInstall
'';
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";
};
})