Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / clojure.scm
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 ;;;
5 ;;; This file is part of GNU Guix.
6 ;;;
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
11 ;;;
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
16 ;;;
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20 (define-module (gnu packages clojure)
21 #:use-module (gnu packages)
22 #:use-module ((guix licenses) #:prefix license:)
23 #:use-module (guix packages)
24 #:use-module (guix download)
25 #:use-module (guix git-download)
26 #:use-module (guix build-system ant)
27 #:use-module (guix build-system clojure)
28 #:use-module (ice-9 match))
29
30 (define-public clojure
31 (let* ((lib (lambda (prefix version hash)
32 (origin (method url-fetch)
33 (uri (string-append "https://github.com/clojure/"
34 prefix version ".tar.gz"))
35 (sha256 (base32 hash)))))
36 ;; The libraries below are needed to run the tests.
37 (libraries
38 `(("core-specs-alpha-src"
39 ,(lib "core.specs.alpha/archive/core.specs.alpha-"
40 "0.1.24"
41 "0v2a0svf1ar2y42ajxwsjr7zmm5j7pp2zwrd2jh3k7xzd1p9x1fv"))
42 ("data-generators-src"
43 ,(lib "data.generators/archive/data.generators-"
44 "0.1.2"
45 "0kki093jp4ckwxzfnw8ylflrfqs8b1i1wi9iapmwcsy328dmgzp1"))
46 ("spec-alpha-src"
47 ,(lib "spec.alpha/archive/spec.alpha-"
48 "0.1.143"
49 "00alf0347licdn773w2jarpllyrbl52qz4d8mw61anjksacxylzz"))
50 ("test-check-src"
51 ,(lib "test.check/archive/test.check-"
52 "0.9.0"
53 "0p0mnyhr442bzkz0s4k5ra3i6l5lc7kp6ajaqkkyh4c2k5yck1md"))
54 ("test-generative-src"
55 ,(lib "test.generative/archive/test.generative-"
56 "0.5.2"
57 "1pjafy1i7yblc7ixmcpfq1lfbyf3jaljvkgrajn70sws9xs7a9f8"))
58 ("tools-namespace-src"
59 ,(lib "tools.namespace/archive/tools.namespace-"
60 "0.2.11"
61 "10baak8v0hnwz2hr33bavshm7y49mmn9zsyyms1dwjz45p5ymhy0"))))
62 (library-names (match libraries
63 (((library-name _) ...)
64 library-name))))
65
66 (package
67 (name "clojure")
68 (version "1.9.0")
69 (source
70 (origin
71 (method url-fetch)
72 (uri
73 (string-append "https://github.com/clojure/clojure/archive/clojure-"
74 version ".tar.gz"))
75 (sha256
76 (base32 "0xjbzcw45z32vsn9pifp7ndysjzqswp5ig0jkjpivigh2ckkdzha"))))
77 (build-system ant-build-system)
78 (arguments
79 `(#:imported-modules ((guix build clojure-utils)
80 (guix build guile-build-system)
81 ,@%ant-build-system-modules)
82 #:modules ((guix build ant-build-system)
83 (guix build clojure-utils)
84 (guix build java-utils)
85 (guix build utils)
86 (srfi srfi-26))
87 #:test-target "test"
88 #:phases
89 (modify-phases %standard-phases
90 (add-after 'unpack 'unpack-library-sources
91 (lambda* (#:key inputs #:allow-other-keys)
92 (define (extract-library name)
93 (mkdir-p name)
94 (with-directory-excursion name
95 (invoke "tar"
96 "--extract"
97 "--verbose"
98 "--file" (assoc-ref inputs name)
99 "--strip-components=1"))
100 (copy-recursively (string-append name "/src/main/clojure/")
101 "src/clj/"))
102 (for-each extract-library ',library-names)
103 #t))
104 (add-after 'unpack-library-sources 'fix-manifest-classpath
105 (lambda _
106 (substitute* "build.xml"
107 (("<attribute name=\"Class-Path\" value=\".\"/>") ""))
108 #t))
109 (add-after 'build 'build-javadoc ant-build-javadoc)
110 (replace 'install (install-jars "./"))
111 (add-after 'install-license-files 'install-doc
112 (cut install-doc #:doc-dirs '("doc/clojure/") <...>))
113 (add-after 'install-doc 'install-javadoc
114 (install-javadoc "target/javadoc/")))))
115 (native-inputs libraries)
116 (home-page "https://clojure.org/")
117 (synopsis "Lisp dialect running on the JVM")
118 (description "Clojure is a dynamic, general-purpose programming language,
119 combining the approachability and interactive development of a scripting
120 language with an efficient and robust infrastructure for multithreaded
121 programming. Clojure is a compiled language, yet remains completely dynamic
122 – every feature supported by Clojure is supported at runtime. Clojure
123 provides easy access to the Java frameworks, with optional type hints and type
124 inference, to ensure that calls to Java can avoid reflection.
125
126 Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy
127 and a powerful macro system. Clojure is predominantly a functional programming
128 language, and features a rich set of immutable, persistent data structures.
129 When mutable state is needed, Clojure offers a software transactional memory
130 system and reactive Agent system that ensure clean, correct, multithreaded
131 designs.")
132 ;; Clojure is licensed under EPL1.0
133 ;; ASM bytecode manipulation library is licensed under BSD-3
134 ;; Guava Murmur3 hash implementation is licensed under APL2.0
135 ;; src/clj/repl.clj is licensed under CPL1.0
136
137 ;; See readme.html or readme.txt for details.
138 (license (list license:epl1.0
139 license:bsd-3
140 license:asl2.0
141 license:cpl1.0)))))
142
143 (define-public clojure-algo-generic
144 (package
145 (name "clojure-algo-generic")
146 (version "0.1.3")
147 (source
148 (origin
149 (method url-fetch)
150 (uri
151 (string-append "https://github.com/clojure/algo.generic/archive"
152 "/algo.generic-" version ".tar.gz"))
153 (sha256
154 (base32 "12w9681i545gp1af4576z1qbixwps1j13c16fmcc7zsb0bd1zr7w"))))
155 (build-system clojure-build-system)
156 (arguments
157 '(#:source-dirs '("src/main/clojure/")
158 #:test-dirs '("src/test/clojure/")
159 #:doc-dirs '()))
160 (synopsis "Generic versions of common functions")
161 (description
162 "Generic versions of commonly used functions, implemented as multimethods
163 that can be implemented for any data type.")
164 (home-page "https://github.com/clojure/algo.generic")
165 (license license:epl1.0)))
166
167 (define-public clojure-algo-monads
168 (package
169 (name "clojure-algo-monads")
170 (version "0.1.6")
171 (source
172 (origin
173 (method url-fetch)
174 (uri
175 (string-append "https://github.com/clojure/algo.monads/archive"
176 "/algo.monads-" version ".tar.gz"))
177 (sha256
178 (base32 "14gbvfgmrda990h45yn7zag83vp1kdkz4f4yzmyvkr0sjihlgdmq"))))
179 (build-system clojure-build-system)
180 (arguments
181 '(#:source-dirs '("src/main/clojure/")
182 #:test-dirs '("src/test/clojure/")
183 #:doc-dirs '()))
184 (native-inputs
185 `(("clojure-tools-macro" ,clojure-tools-macro)))
186 (synopsis
187 "Monad Macros and Definitions")
188 (description
189 "This library contains the most commonly used monads as well as macros for
190 defining and using monads and useful monadic functions.")
191 (home-page "https://github.com/clojure/algo.monads")
192 (license license:epl1.0)))
193
194 (define-public clojure-core-match
195 (let ((commit "1837ffbd4a150e8f3953b2d9ed5cf4a4ad3720a7")
196 (revision "1")) ; this is the 1st commit buildable with clojure 1.9
197 (package
198 (name "clojure-core-match")
199 (version (git-version "0.3.0-alpha5" revision commit))
200 (source (origin
201 (method git-fetch)
202 (uri (git-reference
203 (url "https://github.com/clojure/core.match.git")
204 (commit commit)))
205 (file-name (git-file-name name version))
206 (sha256
207 (base32
208 "04bdlp5dgkrqzrz0lw3mfwmygj2218qnm1cz3dkb9wy4m0238s4d"))))
209 (build-system clojure-build-system)
210 (arguments
211 '(#:source-dirs '("src/main/clojure")
212 #:test-dirs '("src/test/clojure")
213 #:doc-dirs '()))
214 (synopsis "Optimized pattern matching for Clojure")
215 (description
216 "An optimized pattern matching library for Clojure.
217 It supports Clojure 1.5.1 and later as well as ClojureScript.")
218 (home-page "https://github.com/clojure/core.match")
219 (license license:epl1.0))))
220
221 (define-public clojure-instaparse
222 (let ((commit "dcfffad5b065e750f0f5835f017cdd8188b8ca2e")
223 (version "1.4.9")) ; upstream forget to tag this release
224 (package
225 (name "clojure-instaparse")
226 (version version)
227 (source (origin
228 (method git-fetch)
229 (uri (git-reference
230 (url "https://github.com/Engelberg/instaparse.git")
231 (commit commit)))
232 (file-name (git-file-name name version))
233 (sha256
234 (base32
235 "002mrgin4z3dqy88r1lak7smd0m7x8d22vmliw0m6w6mh5pa17lk"))))
236 (build-system clojure-build-system)
237 (arguments
238 '(#:doc-dirs '("docs/")))
239 (synopsis "No grammar left behind")
240 (description
241 "Instaparse aims to be the simplest way to build parsers in Clojure.
242
243 @itemize
244 @item Turns @emph{standard EBNF or ABNF notation} for context-free grammars
245 into an executable parser that takes a string as an input and produces a parse
246 tree for that string.
247
248 @item @dfn{No Grammar Left Behind}: Works for @emph{any} context-free grammar,
249 including @emph{left-recursive}, @emph{right-recursive}, and @emph{ambiguous}
250 grammars.
251
252 @item Extends the power of context-free grammars with PEG-like syntax for
253 lookahead and negative lookahead.
254
255 @item Supports both of Clojure's most popular tree formats (hiccup and enlive)
256 as output targets
257
258 @item Detailed reporting of parse errors.
259
260 @item Optionally produces lazy sequence of all parses (especially useful for
261 diagnosing and debugging ambiguous grammars).
262
263 @item ``Total parsing'' mode where leftover string is embedded in the parse
264 tree.
265
266 @item Optional combinator library for building grammars programmatically.
267
268 @item Performant.
269 @end itemize")
270 (home-page "https://github.com/Engelberg/instaparse")
271 (license license:epl1.0))))
272
273 (define-public clojure-tools-macro
274 (package
275 (name "clojure-tools-macro")
276 (version "0.1.5")
277 (source
278 (origin
279 (method url-fetch)
280 (uri
281 (string-append "https://github.com/clojure/tools.macro/archive"
282 "/tools.macro-" version ".tar.gz"))
283 (sha256
284 (base32 "0fs64a0g63xx6g7sj6vrsqknhl90s0isf6k053nw8vv5prfzc7v6"))))
285 (build-system clojure-build-system)
286 (arguments
287 '(#:source-dirs '("src/main/clojure/")
288 #:test-dirs '("src/test/clojure/")
289 #:doc-dirs '()))
290 (synopsis "Utilities for macro writers")
291 (description "Tools for writing macros.")
292 (home-page "https://github.com/clojure/tools.macro")
293 (license license:epl1.0)))