biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / development / tools / misc / clojure-lsp / default.nix
blobe1956f7ea8bf344b1c6358e454003e8c12345ba1
1 { lib
2 , stdenv
3 , buildGraalvmNativeImage
4 , babashka
5 , fetchurl
6 , fetchFromGitHub
7 , clojure
8 , writeScript
9 , testers
10 , clojure-lsp
13 buildGraalvmNativeImage rec {
14   pname = "clojure-lsp";
15   version = "2023.08.06-00.28.06";
17   src = fetchFromGitHub {
18     owner = pname;
19     repo = pname;
20     rev = version;
21     sha256 = "sha256-wc7M2cPRtdaRzZn3GNu/aCbQ2VqxiDxvu/b7qnBVUBo=";
22   };
24   jar = fetchurl {
25     url = "https://github.com/clojure-lsp/clojure-lsp/releases/download/${version}/clojure-lsp-standalone.jar";
26     sha256 = "c301821ac6914999a44f5c1cd371d46b248fe9a2e31d43a666d0bc2656cfdd78";
27   };
29   extraNativeImageBuildArgs = [
30     "--no-fallback"
31     "--native-image-info"
32   ];
34   doCheck = true;
35   checkPhase = ''
36     runHook preCheck
38     export HOME="$(mktemp -d)"
39     ./${pname} --version | fgrep -q '${version}'
40   ''
41   # TODO: fix classpath issue per https://github.com/NixOS/nixpkgs/pull/153770
42   #${babashka}/bin/bb integration-test ./${pname}
43   + ''
44     runHook postCheck
45   '';
47   passthru.tests.version = testers.testVersion {
48     inherit version;
49     package = clojure-lsp;
50     command = "clojure-lsp --version";
51   };
53   passthru.updateScript = writeScript "update-clojure-lsp" ''
54     #!/usr/bin/env nix-shell
55     #!nix-shell -i bash -p curl common-updater-scripts gnused jq nix
57     set -eu -o pipefail
59     latest_version=$(curl -s https://api.github.com/repos/clojure-lsp/clojure-lsp/releases/latest | jq --raw-output .tag_name)
61     old_jar_hash=$(nix-instantiate --eval --strict -A "clojure-lsp.jar.drvAttrs.outputHash" | tr -d '"' | sed -re 's|[+]|\\&|g')
63     curl -o clojure-lsp-standalone.jar -sL https://github.com/clojure-lsp/clojure-lsp/releases/download/$latest_version/clojure-lsp-standalone.jar
64     new_jar_hash=$(nix-hash --flat --type sha256 clojure-lsp-standalone.jar | sed -re 's|[+]|\\&|g')
66     rm -f clojure-lsp-standalone.jar
68     nixFile=$(nix-instantiate --eval --strict -A "clojure-lsp.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')
70     sed -i "$nixFile" -re "s|\"$old_jar_hash\"|\"$new_jar_hash\"|"
71     update-source-version clojure-lsp "$latest_version"
72   '';
74   meta = with lib; {
75     description = "Language Server Protocol (LSP) for Clojure";
76     homepage = "https://github.com/clojure-lsp/clojure-lsp";
77     sourceProvenance = with sourceTypes; [ binaryBytecode ];
78     license = licenses.mit;
79     maintainers = with maintainers; [ ericdallo babariviere ];
80   };