at 24.05-pre 3.9 kB view raw
1{ lib, stdenv, fetchurl, installShellFiles, jdk, rlwrap, makeWrapper, writeScript }: 2 3stdenv.mkDerivation (finalAttrs: { 4 pname = "clojure"; 5 version = "1.11.1.1413"; 6 7 src = fetchurl { 8 # https://github.com/clojure/brew-install/releases 9 url = "https://github.com/clojure/brew-install/releases/download/${finalAttrs.version}/clojure-tools-${finalAttrs.version}.tar.gz"; 10 hash = "sha256-k8Olo63KUcWFgGNBmr9myD2/JOoV4f2S95v35mI4H+A="; 11 }; 12 13 nativeBuildInputs = [ 14 installShellFiles 15 makeWrapper 16 ]; 17 18 # See https://github.com/clojure/brew-install/blob/1.10.3/src/main/resources/clojure/install/linux-install.sh 19 installPhase = 20 let 21 binPath = lib.makeBinPath [ rlwrap jdk ]; 22 in 23 '' 24 runHook preInstall 25 26 clojure_lib_dir=$out 27 bin_dir=$out/bin 28 29 echo "Installing libs into $clojure_lib_dir" 30 install -Dm644 deps.edn "$clojure_lib_dir/deps.edn" 31 install -Dm644 example-deps.edn "$clojure_lib_dir/example-deps.edn" 32 install -Dm644 tools.edn "$clojure_lib_dir/tools.edn" 33 install -Dm644 exec.jar "$clojure_lib_dir/libexec/exec.jar" 34 install -Dm644 clojure-tools-${finalAttrs.version}.jar "$clojure_lib_dir/libexec/clojure-tools-${finalAttrs.version}.jar" 35 36 echo "Installing clojure and clj into $bin_dir" 37 substituteInPlace clojure --replace PREFIX $out 38 substituteInPlace clj --replace BINDIR $bin_dir 39 install -Dm755 clojure "$bin_dir/clojure" 40 install -Dm755 clj "$bin_dir/clj" 41 42 wrapProgram $bin_dir/clojure --prefix PATH : $out/bin:${binPath} 43 wrapProgram $bin_dir/clj --prefix PATH : $out/bin:${binPath} 44 45 installManPage clj.1 clojure.1 46 47 runHook postInstall 48 ''; 49 50 doInstallCheck = true; 51 52 installCheckPhase = '' 53 CLJ_CONFIG=$TMPDIR CLJ_CACHE=$TMPDIR/.clj_cache $out/bin/clojure \ 54 -Spath \ 55 -Sverbose \ 56 -Scp $out/libexec/clojure-tools-${finalAttrs.version}.jar 57 ''; 58 59 passthru.updateScript = writeScript "update-clojure" '' 60 #!/usr/bin/env nix-shell 61 #!nix-shell -i bash -p curl common-updater-scripts jq 62 63 set -euo pipefail 64 shopt -s inherit_errexit 65 66 # `jq -r '.[0].name'` results in `v0.0` 67 latest_version="$(curl \ 68 ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \ 69 -fsL "https://api.github.com/repos/clojure/brew-install/tags" \ 70 | jq -r '.[1].name')" 71 72 update-source-version clojure "$latest_version" 73 ''; 74 75 passthru.jdk = jdk; 76 77 meta = with lib; { 78 description = "A Lisp dialect for the JVM"; 79 homepage = "https://clojure.org/"; 80 sourceProvenance = with sourceTypes; [ binaryBytecode ]; 81 license = licenses.epl10; 82 longDescription = '' 83 Clojure is a dynamic programming language that targets the Java 84 Virtual Machine. It is designed to be a general-purpose language, 85 combining the approachability and interactive development of a 86 scripting language with an efficient and robust infrastructure for 87 multithreaded programming. Clojure is a compiled language - it 88 compiles directly to JVM bytecode, yet remains completely 89 dynamic. Every feature supported by Clojure is supported at 90 runtime. Clojure provides easy access to the Java frameworks, with 91 optional type hints and type inference, to ensure that calls to Java 92 can avoid reflection. 93 94 Clojure is a dialect of Lisp, and shares with Lisp the code-as-data 95 philosophy and a powerful macro system. Clojure is predominantly a 96 functional programming language, and features a rich set of immutable, 97 persistent data structures. When mutable state is needed, Clojure 98 offers a software transactional memory system and reactive Agent 99 system that ensure clean, correct, multithreaded designs. 100 ''; 101 maintainers = with maintainers; [ jlesquembre thiagokokada ]; 102 platforms = platforms.unix; 103 }; 104})