1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
3 ;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
4 ;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2019 Jesse Gibbons <jgibbons2357+guix@gmail.com>
6 ;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
8 ;;; This file is part of GNU Guix.
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23 (define-module (gnu packages clojure)
24 #:use-module (gnu packages)
25 #:use-module (gnu packages java)
26 #:use-module ((guix licenses) #:prefix license:)
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix git-download)
30 #:use-module (guix build-system ant)
31 #:use-module (guix build-system clojure)
32 #:use-module (ice-9 match))
34 (define-public clojure
35 (let* ((lib (lambda (prefix version hash)
36 (origin (method url-fetch)
37 (uri (string-append "https://github.com/clojure/"
38 prefix version ".tar.gz"))
39 (sha256 (base32 hash)))))
40 ;; The libraries below are needed to run the tests.
42 `(("core-specs-alpha-src"
43 ,(lib "core.specs.alpha/archive/core.specs.alpha-"
45 "0v2a0svf1ar2y42ajxwsjr7zmm5j7pp2zwrd2jh3k7xzd1p9x1fv"))
46 ("data-generators-src"
47 ,(lib "data.generators/archive/data.generators-"
49 "0kki093jp4ckwxzfnw8ylflrfqs8b1i1wi9iapmwcsy328dmgzp1"))
51 ,(lib "spec.alpha/archive/spec.alpha-"
53 "00alf0347licdn773w2jarpllyrbl52qz4d8mw61anjksacxylzz"))
55 ,(lib "test.check/archive/test.check-"
57 "0p0mnyhr442bzkz0s4k5ra3i6l5lc7kp6ajaqkkyh4c2k5yck1md"))
58 ("test-generative-src"
59 ,(lib "test.generative/archive/test.generative-"
61 "1pjafy1i7yblc7ixmcpfq1lfbyf3jaljvkgrajn70sws9xs7a9f8"))
62 ("tools-namespace-src"
63 ,(lib "tools.namespace/archive/tools.namespace-"
65 "10baak8v0hnwz2hr33bavshm7y49mmn9zsyyms1dwjz45p5ymhy0"))))
66 (library-names (match libraries
67 (((library-name _) ...)
73 (source (let ((name+version (string-append name "-" version)))
77 (url "https://github.com/clojure/clojure")
78 (commit name+version)))
79 (file-name (string-append name+version "-checkout"))
81 (base32 "1kcyv2836acs27vi75hvf3r773ahv2nlh9b3j9xa9m9sdanz1h83")))))
82 (build-system ant-build-system)
86 `(#:imported-modules ((guix build clojure-utils)
87 (guix build guile-build-system)
88 ,@%ant-build-system-modules)
89 #:modules ((guix build ant-build-system)
90 (guix build clojure-utils)
91 (guix build java-utils)
96 (modify-phases %standard-phases
97 (add-after 'unpack 'unpack-library-sources
98 (lambda* (#:key inputs #:allow-other-keys)
99 (define (extract-library name)
101 (with-directory-excursion name
105 "--file" (assoc-ref inputs name)
106 "--strip-components=1"))
107 (copy-recursively (string-append name "/src/main/clojure/")
109 (for-each extract-library ',library-names)
111 (add-after 'unpack-library-sources 'fix-manifest-classpath
113 (substitute* "build.xml"
114 (("<attribute name=\"Class-Path\" value=\".\"/>") ""))
116 (add-after 'build 'build-javadoc ant-build-javadoc)
117 (replace 'install (install-jars "./"))
118 (add-after 'install-license-files 'install-doc
119 (cut install-doc #:doc-dirs '("doc/clojure/") <...>))
120 (add-after 'install-doc 'install-javadoc
121 (install-javadoc "target/javadoc/"))
122 (add-after 'install 'make-wrapper
123 (lambda* (#:key inputs outputs #:allow-other-keys)
124 (let* ((out (assoc-ref outputs "out"))
125 (wrapper (string-append out "/bin/clojure")))
126 (mkdir-p (string-append out "/bin"))
127 (with-output-to-file wrapper
134 (assoc-ref inputs "jre") "/bin/java -jar "
135 out "/share/java/clojure.jar \"$@\"\n"))))
136 (chmod wrapper #o555))
138 (native-inputs libraries)
139 (home-page "https://clojure.org/")
140 (synopsis "Lisp dialect running on the JVM")
141 (description "Clojure is a dynamic, general-purpose programming language,
142 combining the approachability and interactive development of a scripting
143 language with an efficient and robust infrastructure for multithreaded
144 programming. Clojure is a compiled language, yet remains completely dynamic
145 – every feature supported by Clojure is supported at runtime. Clojure
146 provides easy access to the Java frameworks, with optional type hints and type
147 inference, to ensure that calls to Java can avoid reflection.
149 Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy
150 and a powerful macro system. Clojure is predominantly a functional programming
151 language, and features a rich set of immutable, persistent data structures.
152 When mutable state is needed, Clojure offers a software transactional memory
153 system and reactive Agent system that ensure clean, correct, multithreaded
155 ;; Clojure is licensed under EPL1.0
156 ;; ASM bytecode manipulation library is licensed under BSD-3
157 ;; Guava Murmur3 hash implementation is licensed under APL2.0
158 ;; src/clj/repl.clj is licensed under CPL1.0
160 ;; See readme.html or readme.txt for details.
161 (license (list license:epl1.0
166 (define-public clojure-algo-generic
168 (name "clojure-algo-generic")
174 (url "https://github.com/clojure/algo.generic")
175 (commit (string-append "algo.generic-" version))))
176 (file-name (git-file-name name version))
178 (base32 "1s6q10qp276dcpzv06bq1q3bvkvlw03qhmncqcs9cc6p9lc0w4p4"))))
179 (build-system clojure-build-system)
181 '(#:source-dirs '("src/main/clojure/")
182 #:test-dirs '("src/test/clojure/")
184 (synopsis "Generic versions of common functions")
186 "Generic versions of commonly used functions, implemented as multimethods
187 that can be implemented for any data type.")
188 (home-page "https://github.com/clojure/algo.generic")
189 (license license:epl1.0)))
191 (define-public clojure-algo-monads
193 (name "clojure-algo-monads")
199 (url "https://github.com/clojure/algo.monads")
200 (commit (string-append "algo.monads-" version))))
201 (file-name (git-file-name name version))
203 (base32 "0mv3ba72hyhgasg2k3zy83ij61gak6cs4d6qgh8123z3j02mbh8p"))))
204 (build-system clojure-build-system)
206 '(#:source-dirs '("src/main/clojure/")
207 #:test-dirs '("src/test/clojure/")
210 `(("clojure-tools-macro" ,clojure-tools-macro)))
212 "Monad Macros and Definitions")
214 "This library contains the most commonly used monads as well as macros for
215 defining and using monads and useful monadic functions.")
216 (home-page "https://github.com/clojure/algo.monads")
217 (license license:epl1.0)))
219 (define-public clojure-core-match
220 (let ((commit "1837ffbd4a150e8f3953b2d9ed5cf4a4ad3720a7")
221 (revision "1")) ; this is the 1st commit buildable with clojure 1.9
223 (name "clojure-core-match")
224 (version (git-version "0.3.0-alpha5" revision commit))
228 (url "https://github.com/clojure/core.match")
230 (file-name (git-file-name name version))
233 "04bdlp5dgkrqzrz0lw3mfwmygj2218qnm1cz3dkb9wy4m0238s4d"))))
234 (build-system clojure-build-system)
236 '(#:source-dirs '("src/main/clojure")
237 #:test-dirs '("src/test/clojure")
239 (synopsis "Optimized pattern matching for Clojure")
241 "An optimized pattern matching library for Clojure.
242 It supports Clojure 1.5.1 and later as well as ClojureScript.")
243 (home-page "https://github.com/clojure/core.match")
244 (license license:epl1.0))))
246 (define-public clojure-instaparse
247 (let ((commit "dcfffad5b065e750f0f5835f017cdd8188b8ca2e")
248 (version "1.4.9")) ; upstream forget to tag this release
250 (name "clojure-instaparse")
255 (url "https://github.com/Engelberg/instaparse")
257 (file-name (git-file-name name version))
260 "002mrgin4z3dqy88r1lak7smd0m7x8d22vmliw0m6w6mh5pa17lk"))))
261 (build-system clojure-build-system)
263 '(#:doc-dirs '("docs/")))
264 (synopsis "No grammar left behind")
266 "Instaparse aims to be the simplest way to build parsers in Clojure.
269 @item Turns @emph{standard EBNF or ABNF notation} for context-free grammars
270 into an executable parser that takes a string as an input and produces a parse
271 tree for that string.
273 @item @dfn{No Grammar Left Behind}: Works for @emph{any} context-free grammar,
274 including @emph{left-recursive}, @emph{right-recursive}, and @emph{ambiguous}
277 @item Extends the power of context-free grammars with PEG-like syntax for
278 lookahead and negative lookahead.
280 @item Supports both of Clojure's most popular tree formats (hiccup and enlive)
283 @item Detailed reporting of parse errors.
285 @item Optionally produces lazy sequence of all parses (especially useful for
286 diagnosing and debugging ambiguous grammars).
288 @item ``Total parsing'' mode where leftover string is embedded in the parse
291 @item Optional combinator library for building grammars programmatically.
295 (home-page "https://github.com/Engelberg/instaparse")
296 (license license:epl1.0))))
298 (define-public clojure-tools-macro
300 (name "clojure-tools-macro")
306 (url "https://github.com/clojure/tools.macro")
307 (commit (string-append "tools.macro-" version))))
308 (file-name (git-file-name name version))
310 (base32 "14mdxqkwja0cffmyfav5pbcli2qvw1mjdgz0n619a2z2036andx8"))))
311 (build-system clojure-build-system)
313 '(#:source-dirs '("src/main/clojure/")
314 #:test-dirs '("src/test/clojure/")
316 (synopsis "Utilities for macro writers")
317 (description "Tools for writing macros.")
318 (home-page "https://github.com/clojure/tools.macro")
319 (license license:epl1.0)))
321 (define-public clojure-tools-cli
323 (name "clojure-tools-cli")
325 (home-page "https://github.com/clojure/tools.cli")
330 (commit (string-append "tools.cli-" version))))
331 (file-name (git-file-name name version))
333 (base32 "1yqlm8lwbcjm0dp032z7vzc4bdlmc4jixznvf4adsqhvqw85hvj2"))))
334 (build-system clojure-build-system)
336 '(#:source-dirs '("src/main/clojure/")
337 #:test-dirs '("src/test/clojure/")
339 (synopsis "Clojure library for working with command-line arguments")
341 "The @code{tools.cli} library provides Clojure programmers with tools to
342 work with command-line arguments.")
343 (license license:epl1.0)))