2021-09-22 15:38:15 +00:00
|
|
|
{ lib, stdenv, graalvm11-ce, babashka, fetchurl, fetchFromGitHub, clojure, writeScript }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-26 19:14:03 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "clojure-lsp";
|
2021-10-04 12:37:57 +00:00
|
|
|
version = "2021.09.30-15.28.01";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-19 19:06:45 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = pname;
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2021-10-04 12:37:57 +00:00
|
|
|
sha256 = "i7HCVcQa35pRnk7uXf+8PQ4IMpdSVrT7FKvguvzOvj4=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-04-26 19:14:03 +00:00
|
|
|
jar = fetchurl {
|
|
|
|
url = "https://github.com/clojure-lsp/clojure-lsp/releases/download/${version}/clojure-lsp.jar";
|
2021-10-04 12:37:57 +00:00
|
|
|
sha256 = "27a1ca0ca96cf0b5177a76679c6b7d09e6e02dca4c85fd252f7b2c43ef39b89a";
|
2021-02-19 19:06:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GRAALVM_HOME = graalvm11-ce;
|
2021-04-26 19:14:03 +00:00
|
|
|
CLOJURE_LSP_JAR = jar;
|
2021-06-28 23:13:55 +00:00
|
|
|
CLOJURE_LSP_XMX = "-J-Xmx4g";
|
|
|
|
|
2021-07-14 22:03:04 +00:00
|
|
|
buildInputs = [ graalvm11-ce clojure ];
|
2021-02-19 19:06:45 +00:00
|
|
|
|
|
|
|
buildPhase = with lib; ''
|
|
|
|
runHook preBuild
|
|
|
|
|
2021-10-04 12:37:57 +00:00
|
|
|
# https://github.com/clojure-lsp/clojure-lsp/blob/2021.09.30-15.28.01/graalvm/native-unix-compile.sh#L19-L24
|
|
|
|
args=("-jar" "$CLOJURE_LSP_JAR"
|
|
|
|
"-H:CLibraryPath=${graalvm11-ce.lib}/lib"
|
|
|
|
"-H:+ReportExceptionStackTraces"
|
|
|
|
"--verbose"
|
|
|
|
"--no-fallback"
|
|
|
|
"--native-image-info"
|
|
|
|
"$CLOJURE_LSP_XMX")
|
|
|
|
|
|
|
|
native-image ''${args[@]}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-19 19:06:45 +00:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
2021-01-05 17:05:55 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
installPhase = ''
|
2021-02-19 19:06:45 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
install -Dm755 ./clojure-lsp $out/bin/clojure-lsp
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
export HOME="$(mktemp -d)"
|
|
|
|
./clojure-lsp --version | fgrep -q '${version}'
|
2021-09-18 10:52:07 +00:00
|
|
|
${babashka}/bin/bb integration-test ./clojure-lsp
|
2021-02-19 19:06:45 +00:00
|
|
|
|
|
|
|
runHook postCheck
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-09-22 15:38:15 +00:00
|
|
|
passthru.updateScript = writeScript "update-clojure-lsp" ''
|
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p curl common-updater-scripts gnused jq nix
|
|
|
|
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
|
|
latest_version=$(curl -s https://api.github.com/repos/clojure-lsp/clojure-lsp/releases/latest | jq --raw-output .tag_name)
|
|
|
|
|
|
|
|
old_jar_hash=$(nix-instantiate --eval --strict -A "clojure-lsp.jar.drvAttrs.outputHash" | tr -d '"' | sed -re 's|[+]|\\&|g')
|
|
|
|
|
|
|
|
curl -o clojure-lsp.jar -sL https://github.com/clojure-lsp/clojure-lsp/releases/download/$latest_version/clojure-lsp.jar
|
|
|
|
new_jar_hash=$(nix-hash --flat --type sha256 clojure-lsp.jar | sed -re 's|[+]|\\&|g')
|
|
|
|
|
|
|
|
rm -f clojure-lsp.jar
|
|
|
|
|
|
|
|
nixFile=$(nix-instantiate --eval --strict -A "clojure-lsp.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')
|
|
|
|
|
|
|
|
sed -i "$nixFile" -re "s|\"$old_jar_hash\"|\"$new_jar_hash\"|"
|
|
|
|
update-source-version clojure-lsp "$latest_version"
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Language Server Protocol (LSP) for Clojure";
|
2021-04-26 19:14:03 +00:00
|
|
|
homepage = "https://github.com/clojure-lsp/clojure-lsp";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.mit;
|
2021-06-28 23:13:55 +00:00
|
|
|
maintainers = with maintainers; [ ericdallo babariviere ];
|
2021-02-19 19:06:45 +00:00
|
|
|
platforms = graalvm11-ce.meta.platforms;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|