clojure.scm 14 KB

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