nixpkgs/pkgs/development/tools/misc/clojure-lsp/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
2.2 KiB
Nix
Raw Normal View History

{ lib, stdenv, buildGraalvmNativeImage, babashka, fetchurl, fetchFromGitHub, clojure, writeScript }:
buildGraalvmNativeImage rec {
pname = "clojure-lsp";
version = "2023.04.19-12.43.29";
src = fetchFromGitHub {
2021-02-04 03:56:20 +00:00
owner = pname;
repo = pname;
rev = version;
sha256 = "sha256-Y3zBkNp8rTQY8yjSeZDIKHgpMEDLe3XBlEWeuc5H3mk=";
};
jar = fetchurl {
url = "https://github.com/clojure-lsp/clojure-lsp/releases/download/${version}/clojure-lsp-standalone.jar";
sha256 = "df6b582a39183c271a8d00ddf4e3cf020b9e872e6fad2c13bf7de46e940ff4d6";
2021-02-04 03:56:20 +00:00
};
extraNativeImageBuildArgs = [
"--no-fallback"
"--native-image-info"
];
2021-02-04 03:56:20 +00:00
doCheck = true;
checkPhase = ''
runHook preCheck
export HOME="$(mktemp -d)"
./${pname} --version | fgrep -q '${version}'
2022-01-10 15:28:17 +00:00
''
# TODO: fix classpath issue per https://github.com/NixOS/nixpkgs/pull/153770
#${babashka}/bin/bb integration-test ./${pname}
+ ''
runHook postCheck
'';
2021-09-14 14:26:21 +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
2021-09-14 14:26:21 +00:00
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')
2021-09-14 14:26:21 +00:00
curl -o clojure-lsp-standalone.jar -sL https://github.com/clojure-lsp/clojure-lsp/releases/download/$latest_version/clojure-lsp-standalone.jar
new_jar_hash=$(nix-hash --flat --type sha256 clojure-lsp-standalone.jar | sed -re 's|[+]|\\&|g')
2021-09-14 14:26:21 +00:00
rm -f clojure-lsp-standalone.jar
2021-09-14 14:26:21 +00:00
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"
'';
meta = with lib; {
description = "Language Server Protocol (LSP) for Clojure";
homepage = "https://github.com/clojure-lsp/clojure-lsp";
sourceProvenance = with sourceTypes; [ binaryBytecode ];
license = licenses.mit;
maintainers = with maintainers; [ ericdallo babariviere ];
};
}