gnu: Use 'install-file' instead of 'mkdir-p' and 'copy-file' in obvious cases.
[jackhill/guix/guix.git] / gnu / packages / guile.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015 Christopher Allan Webber <cwebber@dustycloud.org>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (gnu packages guile)
22 #:use-module (guix licenses)
23 #:use-module (gnu packages)
24 #:use-module (gnu packages bash)
25 #:use-module (gnu packages bdw-gc)
26 #:use-module (gnu packages gawk)
27 #:use-module (gnu packages gperf)
28 #:use-module (gnu packages libffi)
29 #:use-module (gnu packages autotools)
30 #:use-module (gnu packages flex)
31 #:use-module (gnu packages libunistring)
32 #:use-module (gnu packages m4)
33 #:use-module (gnu packages multiprecision)
34 #:use-module (gnu packages pkg-config)
35 #:use-module (gnu packages readline)
36 #:use-module (gnu packages ncurses)
37 #:use-module (gnu packages ed)
38 #:use-module (gnu packages base)
39 #:use-module (gnu packages texinfo)
40 #:use-module (gnu packages gettext)
41 #:use-module (gnu packages gdbm)
42 #:use-module (guix packages)
43 #:use-module (guix download)
44 #:use-module (guix git-download)
45 #:use-module (guix build-system gnu)
46 #:use-module (guix build-system trivial)
47 #:use-module (guix utils)
48 #:use-module (ice-9 match))
49
50 ;;; Commentary:
51 ;;;
52 ;;; GNU Guile, and modules and extensions.
53 ;;;
54 ;;; Code:
55
56 (define-public guile-1.8
57 (package
58 (name "guile")
59 (version "1.8.8")
60 (source (origin
61 (method url-fetch)
62 (uri (string-append "mirror://gnu/guile/guile-" version
63 ".tar.gz"))
64 (sha256
65 (base32
66 "0l200a0v7h8bh0cwz6v7hc13ds39cgqsmfrks55b1rbj5vniyiy3"))
67 (patches (list (search-patch "guile-1.8-cpp-4.5.patch")))))
68 (build-system gnu-build-system)
69 (arguments '(#:configure-flags '("--disable-error-on-warning")
70
71 ;; Insert a phase before `configure' to patch things up.
72 #:phases (alist-cons-before
73 'configure
74 'patch-stuff
75 (lambda* (#:key outputs #:allow-other-keys)
76 ;; Add a call to `lt_dladdsearchdir' so that
77 ;; `libguile-readline.so' & co. are in the
78 ;; loader's search path.
79 (substitute* "libguile/dynl.c"
80 (("lt_dlinit.*$" match)
81 (format #f
82 " ~a~% lt_dladdsearchdir(\"~a/lib\");~%"
83 match
84 (assoc-ref outputs "out"))))
85
86 ;; The usual /bin/sh...
87 (substitute* "ice-9/popen.scm"
88 (("/bin/sh") (which "sh"))))
89 %standard-phases)))
90 (inputs `(("gawk" ,gawk)
91 ("readline" ,readline)))
92
93 ;; Since `guile-1.8.pc' has "Libs: ... -lgmp -lltdl", these must be
94 ;; propagated.
95 (propagated-inputs `(("gmp" ,gmp)
96 ("libltdl" ,libltdl)))
97
98 ;; When cross-compiling, a native version of Guile itself is needed.
99 (self-native-input? #t)
100
101 (native-search-paths
102 (list (search-path-specification
103 (variable "GUILE_LOAD_PATH")
104 (files '("share/guile/site")))))
105
106 (synopsis "Scheme implementation intended especially for extensions")
107 (description
108 "Guile is the GNU Ubiquitous Intelligent Language for Extensions, the
109 official extension language of the GNU system. It is an implementation of
110 the Scheme language which can be easily embedded in other applications to
111 provide a convenient means of extending the functionality of the application
112 without requiring the source code to be rewritten.")
113 (home-page "http://www.gnu.org/software/guile/")
114 (license lgpl2.0+)))
115
116 (define-public guile-2.0
117 (package
118 (name "guile")
119 (version "2.0.11")
120 (source (origin
121 (method url-fetch)
122 (uri (string-append "mirror://gnu/guile/guile-" version
123 ".tar.xz"))
124 (sha256
125 (base32
126 "1qh3j7308qvsjgwf7h94yqgckpbgz2k3yqdkzsyhqcafvfka9l5f"))
127 (patches (list (search-patch "guile-arm-fixes.patch")))))
128 (build-system gnu-build-system)
129 (native-inputs `(("pkgconfig" ,pkg-config)))
130 (inputs `(("libffi" ,libffi)
131 ("readline" ,readline)
132 ("bash" ,bash)))
133
134 (propagated-inputs
135 `( ;; These ones aren't normally needed here, but since `libguile-2.0.la'
136 ;; reads `-lltdl -lunistring', adding them here will add the needed
137 ;; `-L' flags. As for why the `.la' file lacks the `-L' flags, see
138 ;; <http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/18903>.
139 ("libunistring" ,libunistring)
140
141 ;; Depend on LIBLTDL, not LIBTOOL. That way, we avoid some the extra
142 ;; dependencies that LIBTOOL has, which is helpful during bootstrap.
143 ("libltdl" ,libltdl)
144
145 ;; The headers and/or `guile-2.0.pc' refer to these packages, so they
146 ;; must be propagated.
147 ("bdw-gc" ,libgc)
148 ("gmp" ,gmp)))
149
150 (self-native-input? #t)
151
152 (outputs '("out" "debug"))
153
154 (arguments
155 `(#:phases (alist-cons-before
156 'configure 'pre-configure
157 (lambda* (#:key inputs #:allow-other-keys)
158 ;; Tell (ice-9 popen) the file name of Bash.
159 (let ((bash (assoc-ref inputs "bash")))
160 (substitute* "module/ice-9/popen.scm"
161 (("/bin/sh")
162 (string-append bash "/bin/bash")))))
163 %standard-phases)))
164
165 (native-search-paths
166 (list (search-path-specification
167 (variable "GUILE_LOAD_PATH")
168 (files '("share/guile/site/2.0")))
169 (search-path-specification
170 (variable "GUILE_LOAD_COMPILED_PATH")
171 (files '("share/guile/site/2.0")))))
172
173 (synopsis "Scheme implementation intended especially for extensions")
174 (description
175 "Guile is the GNU Ubiquitous Intelligent Language for Extensions, the
176 official extension language of the GNU system. It is an implementation of
177 the Scheme language which can be easily embedded in other applications to
178 provide a convenient means of extending the functionality of the application
179 without requiring the source code to be rewritten.")
180 (home-page "http://www.gnu.org/software/guile/")
181 (license lgpl3+)))
182
183 (define-public guile-2.0/fixed
184 ;; A package of Guile 2.0 that's rarely changed. It is the one used
185 ;; in the `base' module, and thus changing it entails a full rebuild.
186 guile-2.0)
187
188 (define-public guile-for-guile-emacs
189 (package (inherit guile-2.0)
190 (name "guile-for-guile-emacs")
191 (version "20150510.d8d9a8d")
192 (source (origin
193 (method git-fetch)
194 (uri (git-reference
195 (url "git://git.hcoop.net/git/bpt/guile.git")
196 (commit "d8d9a8da05ec876acba81a559798eb5eeceb5a17")))
197 (sha256
198 (base32
199 "00sprsshy16y8pxjy126hr2adqcvvzzz96hjyjwgg8swva1qh6b0"))))
200 (arguments
201 (substitute-keyword-arguments `(;; Tests aren't passing for now.
202 ;; Obviously we should re-enable this!
203 #:tests? #f
204 ,@(package-arguments guile-2.0))
205 ((#:phases phases)
206 `(modify-phases ,phases
207 (add-after 'unpack 'autogen
208 (lambda _
209 (zero? (system* "sh" "autogen.sh"))))
210 (add-before 'autogen 'patch-/bin/sh
211 (lambda _
212 (substitute* "build-aux/git-version-gen"
213 (("#!/bin/sh") (string-append "#!" (which "sh"))))
214 #t))))))
215 (native-inputs
216 `(("autoconf" ,autoconf)
217 ("automake" ,automake)
218 ("libtool" ,libtool)
219 ("flex" ,flex)
220 ("texinfo" ,texinfo)
221 ("gettext" ,gnu-gettext)
222 ,@(package-native-inputs guile-2.0)))))
223
224 \f
225 ;;;
226 ;;; Extensions.
227 ;;;
228
229 (define-public guile-reader
230 (package
231 (name "guile-reader")
232 (version "0.6.1")
233 (source (origin
234 (method url-fetch)
235 (uri (string-append "mirror://savannah/guile-reader/guile-reader-"
236 version ".tar.gz"))
237 (sha256
238 (base32
239 "020wz5w8z6g79nbqifg2n496wxwkcjzh8xizpv6mz0hczpl155ma"))))
240 (build-system gnu-build-system)
241 (native-inputs `(("pkgconfig" ,pkg-config)
242 ("gperf" ,gperf)))
243 (inputs `(("guile" ,guile-2.0)))
244 (arguments `(#:configure-flags
245 (let ((out (assoc-ref %outputs "out")))
246 (list (string-append "--with-guilemoduledir="
247 out "/share/guile/site/2.0")))))
248 (synopsis "Framework for building readers for GNU Guile")
249 (description
250 "Guile-Reader is a simple framework for building readers for GNU Guile.
251
252 The idea is to make it easy to build procedures that extend Guile’s read
253 procedure. Readers supporting various syntax variants can easily be written,
254 possibly by re-using existing “token readers” of a standard Scheme
255 readers. For example, it is used to implement Skribilo’s R5RS-derived
256 document syntax.
257
258 Guile-Reader’s approach is similar to Common Lisp’s “read table”, but
259 hopefully more powerful and flexible (for instance, one may instantiate as
260 many readers as needed).")
261 (home-page "http://www.nongnu.org/guile-reader/")
262 (license gpl3+)))
263
264 (define-public guile-ncurses
265 (package
266 (name "guile-ncurses")
267 (version "1.6")
268 (source (origin
269 (method url-fetch)
270 (uri (string-append "mirror://gnu/guile-ncurses/guile-ncurses-"
271 version ".tar.gz"))
272 (sha256
273 (base32
274 "0wmk681zzi1wxw543r2s2r84ndnzxp69kr7pc01aw4l55hg7jn73"))))
275 (build-system gnu-build-system)
276 (inputs `(("ncurses" ,ncurses)
277 ("guile" ,guile-2.0)))
278 (arguments
279 '(#:configure-flags (list "--with-ncursesw" ; Unicode support
280 (string-append "--with-guilesitedir="
281 (assoc-ref %outputs "out")
282 "/share/guile/site/2.0"))
283 #:phases (alist-cons-before
284 'check 'change-locale
285 (lambda _
286 ;; Use the locale that's actually available in the build
287 ;; environment.
288 (substitute* "test/f009_form_wide.test"
289 (("en_US\\.utf8")
290 "en_US.UTF-8")))
291 (alist-cons-after
292 'install 'post-install
293 (lambda* (#:key outputs #:allow-other-keys)
294 (let* ((out (assoc-ref outputs "out"))
295 (dir (string-append out "/share/guile/site/"))
296 (files (find-files dir ".scm")))
297 (substitute* files
298 (("\"libguile-ncurses\"")
299 (format #f "\"~a/lib/libguile-ncurses\""
300 out)))))
301 %standard-phases))))
302 (home-page "http://www.gnu.org/software/guile-ncurses/")
303 (synopsis "Guile bindings to ncurses")
304 (description
305 "guile-ncurses provides Guile language bindings for the ncurses
306 library.")
307 (license lgpl3+)))
308
309 (define-public mcron
310 (package
311 (name "mcron")
312 (version "1.0.8")
313 (source (origin
314 (method url-fetch)
315 (uri (string-append "mirror://gnu/mcron/mcron-"
316 version ".tar.gz"))
317 (sha256
318 (base32
319 "0zparwgf01jgl1x53ik71ghabldq6zz18ha4dscps1i0qrzgap1b"))
320 (patches (list (search-patch "mcron-install.patch")))))
321 (build-system gnu-build-system)
322 (native-inputs `(("pkg-config" ,pkg-config)))
323 (inputs `(("ed" ,ed) ("which" ,which) ("guile" ,guile-2.0)))
324 (home-page "http://www.gnu.org/software/mcron/")
325 (synopsis "Run jobs at scheduled times")
326 (description
327 "GNU Mcron is a complete replacement for Vixie cron. It is used to run
328 tasks on a schedule, such as every hour or every Monday. Mcron is written in
329 Guile, so its configuration can be written in Scheme; the original cron
330 format is also supported.")
331 (license gpl3+)))
332
333 (define-public guile-lib
334 (package
335 (name "guile-lib")
336 (version "0.2.2")
337 (source (origin
338 (method url-fetch)
339 (uri (string-append "mirror://savannah/guile-lib/guile-lib-"
340 version ".tar.gz"))
341 (sha256
342 (base32
343 "1f9n2b5b5r75lzjinyk6zp6g20g60msa0jpfrk5hhg4j8cy0ih4b"))))
344 (build-system gnu-build-system)
345 (arguments
346 '(#:phases (alist-cons-before
347 'configure 'patch-module-dir
348 (lambda _
349 (substitute* "src/Makefile.in"
350 (("^moddir[[:blank:]]*=[[:blank:]]*([[:graph:]]+)" _ rhs)
351 (string-append "moddir = " rhs "/2.0\n"))))
352 %standard-phases)))
353 (inputs `(("guile" ,guile-2.0)))
354 (home-page "http://www.nongnu.org/guile-lib/")
355 (synopsis "Collection of useful Guile Scheme modules")
356 (description
357 "Guile-Lib is intended as an accumulation place for pure-scheme Guile
358 modules, allowing for people to cooperate integrating their generic Guile
359 modules into a coherent library. Think \"a down-scaled, limited-scope CPAN
360 for Guile\".")
361
362 ;; The whole is under GPLv3+, but some modules are under laxer
363 ;; distribution terms such as LGPL and public domain. See `COPYING' for
364 ;; details.
365 (license gpl3+)))
366
367 (define-public guile-json
368 (package
369 (name "guile-json")
370 (version "0.4.0")
371 (source (origin
372 (method url-fetch)
373 (uri (string-append "mirror://savannah/guile-json/guile-json-"
374 version ".tar.gz"))
375 (sha256
376 (base32
377 "0v06272rw4ycwzssjf3fzpk2vhpslvl55hz94q80vc6f74j0d5h6"))
378 (modules '((guix build utils)))
379 (snippet
380 ;; Make sure everything goes under .../site/2.0, like Guile's
381 ;; search paths expects.
382 '(substitute* '("Makefile.in" "json/Makefile.in")
383 (("moddir =.*/share/guile/site" all)
384 (string-append all "/2.0"))))))
385 (build-system gnu-build-system)
386 (native-inputs `(("guile" ,guile-2.0)))
387 (home-page "http://savannah.nongnu.org/projects/guile-json/")
388 (synopsis "JSON module for Guile")
389 (description
390 "Guile-json supports parsing and building JSON documents according to the
391 http:://json.org specification. These are the main features:
392 - Strictly complies to http://json.org specification.
393 - Build JSON documents programmatically via macros.
394 - Unicode support for strings.
395 - Allows JSON pretty printing.")
396 (license lgpl3+)))
397
398 (define-public guile-minikanren
399 (package
400 (name "guile-minikanren")
401 (version "20150424.e844d85")
402 (source (origin
403 (method git-fetch)
404 (uri (git-reference
405 (url "https://github.com/ijp/minikanren.git")
406 (commit "e844d85512f8c055d3f96143ee506007389a25e3")))
407 (sha256
408 (base32
409 "0r50jlpzi940jlmxyy3ddqqwmj5r12gb4bcv0ssini9v8km13xz6"))))
410 (build-system trivial-build-system)
411 (arguments
412 `(#:modules
413 ((guix build utils)
414 (ice-9 match))
415 #:builder
416 (begin
417 (use-modules (guix build utils)
418 (ice-9 match))
419 (let* ((out (assoc-ref %outputs "out"))
420 (module-dir (string-append out "/share/guile/site/2.0"))
421 (source (assoc-ref %build-inputs "source"))
422 (doc (string-append out "/share/doc/guile-minikanren"))
423 (scm-files '("minikanren.scm"
424 "minikanren/mkextraforms.scm"
425 "minikanren/mkprelude.scm"
426 "minikanren/mk.scm"))
427 (guild (string-append (assoc-ref %build-inputs "guile")
428 "/bin/guild")))
429 ;; Make installation directories.
430 (mkdir-p (string-append module-dir "/minikanren"))
431 (mkdir-p doc)
432
433 ;; Compile .scm files and install.
434 (chdir source)
435 (setenv "GUILE_AUTO_COMPILE" "0")
436 (for-each (lambda (file)
437 (let* ((dest-file (string-append module-dir "/"
438 file ".scm"))
439 (go-file (match (string-split file #\.)
440 ((base _)
441 (string-append module-dir "/"
442 base ".go")))))
443 ;; Install source module.
444 (copy-file file dest-file)
445 ;; Install compiled module.
446 (unless (zero? (system* guild "compile"
447 "-L" source
448 "-o" go-file
449 file))
450 (error (format #f "Failed to compile ~s to ~s!"
451 file go-file)))))
452 scm-files)
453
454 ;; Also copy over the README.
455 (install-file "README.org" doc)
456 #t))))
457 (inputs
458 `(("guile" ,guile-2.0)))
459 (home-page "https://github.com/ijp/minikanren")
460 (synopsis "MiniKanren declarative logic system, packaged for Guile")
461 (description
462 "MiniKanren is a relational programming extension to the Scheme
463 programming Language, written as a smaller version of Kanren suitable for
464 pedagogical purposes. It is featured in the book, The Reasoned Schemer,
465 written by Dan Friedman, William Byrd, and Oleg Kiselyov.
466
467 This is Ian Price's r6rs packaged version of miniKanren, which deviates
468 slightly from miniKanren mainline.
469
470 See http://minikanren.org/ for more on miniKanren generally.")
471 (license expat)))
472
473
474 ;; There are two guile-gdbm packages, one using the FFI and one with
475 ;; direct C bindings, hence the verbose name.
476
477 (define-public guile-gdbm-ffi
478 (package
479 (name "guile-gdbm-ffi")
480 (version "20120209.fa1d5b6")
481 (source (origin
482 (method git-fetch)
483 (uri (git-reference
484 (url "https://github.com/ijp/guile-gdbm.git")
485 (commit "fa1d5b6231d0e4d096687b378c025f2148c5f246")))
486 (sha256
487 (base32
488 "1j8wrsw7v9w6qkl47xz0rdikg50v16nn6kbs3lgzcymjzpa7babj"))))
489 (build-system trivial-build-system)
490 (arguments
491 `(#:modules
492 ((guix build utils))
493 #:builder
494 (begin
495 (use-modules (guix build utils)
496 (system base compile))
497
498 (let* ((out (assoc-ref %outputs "out"))
499 (module-dir (string-append out "/share/guile/site/2.0"))
500 (source (assoc-ref %build-inputs "source"))
501 (doc (string-append out "/share/doc"))
502 (guild (string-append (assoc-ref %build-inputs "guile")
503 "/bin/guild"))
504 (gdbm.scm-dest
505 (string-append module-dir "/gdbm.scm"))
506 (gdbm.go-dest
507 (string-append module-dir "/gdbm.go")))
508 ;; Make installation directories.
509 (mkdir-p module-dir)
510 (mkdir-p doc)
511
512 ;; Switch directory for compiling and installing
513 (chdir source)
514
515 ;; copy the source
516 (copy-file "gdbm.scm" gdbm.scm-dest)
517
518 ;; Patch the FFI
519 (substitute* gdbm.scm-dest
520 (("\\(dynamic-link \"libgdbm\"\\)")
521 (format #f "(dynamic-link \"~a/lib/libgdbm.so\")"
522 (assoc-ref %build-inputs "gdbm"))))
523
524 ;; compile to the destination
525 (compile-file gdbm.scm-dest
526 #:output-file gdbm.go-dest)))))
527 (inputs
528 `(("guile" ,guile-2.0)))
529 (propagated-inputs
530 `(("gdbm" ,gdbm)))
531 (home-page "https://github.com/ijp/guile-gdbm")
532 (synopsis "Guile bindings to the GDBM library via Guile's FFI")
533 (description
534 "Guile bindings to the GDBM key-value storage system, using
535 Guile's foreign function interface.")
536 (license gpl3+)))
537
538 (define-public haunt
539 (package
540 (name "haunt")
541 (version "0.1")
542 (source (origin
543 (method url-fetch)
544 (uri (string-append "http://files.dthompson.us/haunt/haunt-"
545 version ".tar.gz"))
546 (sha256
547 (base32
548 "15q1qwjnay7k90ppqrzqsmikvwyj61mjvf1zahyd9gm4vi2fgb3x"))))
549 (build-system gnu-build-system)
550 (inputs
551 `(("guile" ,guile-2.0)))
552 (synopsis "Functional static site generator")
553 (description "Haunt is a static site generator written in Guile
554 Scheme. Haunt features a functional build system and an extensible
555 interface for reading articles in any format.")
556 (home-page "http://haunt.dthompson.us")
557 (license gpl3+)))
558
559 (define-public guile-redis
560 (package
561 (name "guile-redis")
562 (version "0.1.0")
563 (source (origin
564 (method url-fetch)
565 (uri (string-append "mirror://savannah/guile-redis/guile-redis-"
566 version ".tar.gz"))
567 (sha256
568 (base32
569 "0vx6if6b4r3kwx64vzbs6vpc0cpcr85x11w9vkzq27gw8n7isv56"))
570 (modules '((guix build utils)))
571 (snippet
572 ;; Make sure everything goes under .../site/2.0, like Guile's
573 ;; search paths expects.
574 '(substitute* '("Makefile.in"
575 "redis/Makefile.in"
576 "redis/commands/Makefile.in")
577 (("moddir =.*/share/guile/site" all)
578 (string-append all "/2.0"))))))
579 (build-system gnu-build-system)
580 (native-inputs
581 `(("guile" ,guile-2.0)))
582 (home-page "http://savannah.nongnu.org/projects/guile-redis/")
583 (synopsis "Redis client library for Guile")
584 (description "Guile-redis provides a Scheme interface to the Redis
585 key-value cache and store.")
586 (license lgpl3+)))
587
588 ;;; guile.scm ends here