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