guix-more/more/packages/ocaml.scm

ocaml.scm

1
;;; GNU Guix --- Functional package management for GNU
2
;;; Copyright © 2017 Julien Lepiller <julien@lepiller.eu>
3
;;;
4
;;; This file is part of GNU Guix.
5
;;;
6
;;; GNU Guix is free software; you can redistribute it and/or modify it
7
;;; under the terms of the GNU General Public License as published by
8
;;; the Free Software Foundation; either version 3 of the License, or (at
9
;;; your option) any later version.
10
;;;
11
;;; GNU Guix is distributed in the hope that it will be useful, but
12
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
;;; GNU General Public License for more details.
15
;;;
16
;;; You should have received a copy of the GNU General Public License
17
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
18
19
(define-module (more packages ocaml)
20
  #:use-module (guix packages)
21
  #:use-module (guix download)
22
  #:use-module (guix git-download)
23
  #:use-module (guix utils)
24
  #:use-module (guix build-system gnu)
25
  #:use-module (guix build-system ocaml)
26
  #:use-module ((guix licenses) #:prefix license:)
27
  #:use-module (gnu packages)
28
  #:use-module (gnu packages assembly)
29
  #:use-module (gnu packages base)
30
  #:use-module (gnu packages bison)
31
  #:use-module (gnu packages boost)
32
  #:use-module (gnu packages emacs)
33
  #:use-module (gnu packages flex)
34
  #:use-module (gnu packages llvm)
35
  #:use-module (gnu packages m4)
36
  #:use-module (gnu packages maths)
37
  #:use-module (gnu packages multiprecision)
38
  #:use-module (gnu packages ocaml)
39
  #:use-module (gnu packages perl)
40
  #:use-module (gnu packages protobuf)
41
  #:use-module (gnu packages python)
42
  #:use-module (gnu packages texinfo)
43
  #:use-module (more packages smt))
44
45
;; Janestreet packages are found in a similar way and all need the same patch.
46
(define (janestreet-origin name version hash)
47
  (origin (method url-fetch)
48
          (uri (string-append "https://ocaml.janestreet.com/ocaml-core/"
49
                              (version-major+minor version) "/files/"
50
                              name "-" version ".tar.gz"))
51
          (sha256 (base32 hash))
52
          (modules '((guix build utils)))
53
          (snippet
54
           (let ((pattern (string-append "lib/" name)))
55
             `(begin
56
                ;; install.ml contains an invalid reference to the ppx file and
57
                ;; propagates this error to the generated META file.  It
58
                ;; looks for it in the "lib" directory, but it is installed in
59
                ;; "lib/ocaml/site-lib/package".  This substitute does not change
60
                ;; this file for non ppx packages.
61
                (substitute* "install.ml"
62
                  ((,pattern) (string-append "lib/ocaml/site-lib/" ,name)))
63
                ;; The standard Makefile would try to install janestreet modules
64
                ;; in OCaml's directory in the store, which is read-only.
65
                (substitute* "Makefile"
66
                  (("--prefix")
67
                   "--libdir $(LIBDIR) --prefix")))))))
68
69
;; They also require almost the same set of arguments
70
(define janestreet-arguments
71
  `(#:use-make? #t
72
    #:make-flags
73
    (list (string-append "CONFIGUREFLAGS=--prefix "
74
                         (assoc-ref %outputs "out")
75
                         " --enable-tests")
76
          (string-append "LIBDIR="
77
                         (assoc-ref %outputs "out")
78
                         "/lib/ocaml/site-lib")
79
          ;; for ocaml-bin-prot, otherwise ignored
80
          (string-append "OCAML_TOPLEVEL_PATH="
81
                         (assoc-ref %build-inputs "findlib")
82
                         "/lib/ocaml/site-lib"))
83
    #:phases (modify-phases %standard-phases (delete 'configure))))
84
85
(define-public ocaml-fix
86
  (package
87
    (inherit ocaml)
88
    (version "4.05.0")
89
    (source (origin
90
              (method url-fetch)
91
              (uri (string-append
92
                    "http://caml.inria.fr/pub/distrib/ocaml-"
93
                    (version-major+minor version)
94
                    "/ocaml-" version ".tar.xz"))
95
              (sha256
96
               (base32
97
                "1y9fw1ci9pwnbbrr9nwr8cq8vypcxwdf4akvxard3mxl2jx2g984"))))
98
    (arguments
99
     `(#:modules ((guix build gnu-build-system)
100
                  (guix build utils)
101
                  (web server))
102
       #:phases
103
       (modify-phases %standard-phases
104
         (add-after 'unpack 'patch-/bin/sh-references
105
           (lambda* (#:key inputs #:allow-other-keys)
106
             (let* ((sh (string-append (assoc-ref inputs "bash")
107
                                       "/bin/sh"))
108
                    (quoted-sh (string-append "\"" sh "\"")))
109
               (with-fluids ((%default-port-encoding #f))
110
                 (for-each
111
                  (lambda (file)
112
                    (substitute* file
113
                      (("\"/bin/sh\"")
114
                       (begin
115
                         (format (current-error-port) "\
116
patch-/bin/sh-references: ~a: changing `\"/bin/sh\"' to `~a'~%"
117
                                 file quoted-sh)
118
                         quoted-sh))))
119
                  (find-files "." "\\.ml$"))
120
                 #t))))
121
         (replace 'configure
122
           (lambda* (#:key outputs #:allow-other-keys)
123
             (let* ((out (assoc-ref outputs "out"))
124
                    (mandir (string-append out "/share/man")))
125
               ;; Custom configure script doesn't recognize
126
               ;; --prefix=<PREFIX> syntax (with equals sign).
127
               (zero? (system* "./configure"
128
                               "--prefix" out
129
                               "--mandir" mandir)))))
130
         (replace 'build
131
           (lambda _
132
             (zero? (system* "make" "-j1" ;; fails to build otherwise
133
                             "world.opt"))))
134
         (delete 'check)
135
         (add-after 'install 'check
136
           (lambda _
137
             (with-directory-excursion "testsuite"
138
               (zero? (system* "make" "all"))))))))))
139
140
(define-public ocaml-zed
141
  (package
142
    (name "ocaml-zed")
143
    (version "1.4")
144
    (source (origin
145
              (method url-fetch)
146
              (uri (string-append "https://github.com/diml/zed/archive/"
147
                                  version ".tar.gz"))
148
              (sha256
149
               (base32
150
                "0pvfq9ikhbkv4ksn3k3vzs6wiwkihjav3n81lhxm54z9931gfwnz"))))
151
    (build-system ocaml-build-system)
152
    (propagated-inputs
153
     `(("camomile" ,ocaml-camomile)
154
       ("react" ,ocaml-react)))
155
    (home-page "https://github.com/diml/zed")
156
    (synopsis "Abstract engine for text edition in OCaml")
157
    (description "Zed is an abstract engine for text edition. It can be used to
158
write text editors, edition widgets, readlines, ...
159
160
Zed uses Camomile to fully support the Unicode specification, and implements an
161
UTF-8 encoded string type with validation, and a rope datastructure to achieve
162
efficient operations on large Unicode buffers. Zed also features a regular
163
expression search on ropes.
164
165
To support efficient text edition capabilities, Zed provides macro recording
166
and cursor management facilities.")
167
    (license license:bsd-3)))
168
169
(define-public ocaml-lambda-term
170
  (package
171
    (name "ocaml-lambda-term")
172
    (version "1.10.1")
173
    (home-page "https://github.com/diml/lambda-term")
174
    (source (origin
175
              (method url-fetch)
176
              (uri (string-append home-page "/archive/" version ".tar.gz"))
177
              (sha256
178
               (base32
179
                "1449glcsavcwbcsxbd7wcjz50y8vvin4zwpmkhq8i6jca3f3sknj"))))
180
    (build-system ocaml-build-system)
181
    (propagated-inputs
182
     `(("zed" ,ocaml-zed)
183
       ("lwt" ,ocaml-lwt)
184
       ("react" ,ocaml-react)))
185
    (arguments
186
     `(#:phases
187
       (modify-phases %standard-phases
188
        (add-after 'install 'link-stubs
189
          (lambda* (#:key outputs #:allow-other-keys)
190
            (let* ((out (assoc-ref outputs "out"))
191
                   (stubs (string-append out "/lib/ocaml/site-lib/stubslibs"))
192
                   (lib (string-append out "/lib/ocaml/site-lib/lambda-term")))
193
              (mkdir-p stubs)
194
              (symlink (string-append lib "/dlllambda-term_stubs.so")
195
                       (string-append stubs "/dlllambda-term_stubs.so"))))))))
196
    (synopsis "Terminal manipulation library for OCaml")
197
    (description "Lambda-term is a cross-platform library for manipulating the
198
terminal. It provides an abstraction for keys, mouse events, colors, as well as
199
a set of widgets to write curses-like applications.
200
201
The main objective of lambda-term is to provide a higher level functional
202
interface to terminal manipulation than, for example, ncurses, by providing a
203
native OCaml interface instead of bindings to a C library.
204
205
Lambda-term integrates with zed to provide text edition facilities in console
206
applications.")
207
    (license license:bsd-3)))
208
209
(define-public ocaml-utop
210
  (package
211
    (name "ocaml-utop")
212
    (version "1.19.3")
213
    (source (origin
214
              (method url-fetch)
215
              (uri (string-append "https://github.com/diml/utop/archive/"
216
                                  version ".tar.gz"))
217
              (file-name (string-append name "-" version ".tar.gz"))
218
              (sha256
219
               (base32
220
                "16z02vp9n97iax4fqpbi7v86r75vbabxvnd1rirh8w2miixs1g4x"))))
221
    (build-system ocaml-build-system)
222
    (native-inputs
223
     `(("cppo" ,ocaml-cppo)))
224
    (propagated-inputs
225
     `(("lambda-term" ,ocaml-lambda-term)
226
       ("lwt" ,ocaml-lwt)
227
       ("react" ,ocaml-react)))
228
    (home-page "https://github.com/diml/utop")
229
    (synopsis "Universal toplevel for OCaml")
230
    (description "utop is an improved toplevel for OCaml.  It can run in a
231
terminal or in Emacs.  It supports line edition, history, real-time and context
232
sensitive completion, colors, and more.
233
234
It integrates with the tuareg mode in Emacs.")
235
    (license license:bsd-3)))
236
237
(define-public proof-general2
238
  (package
239
    (name "proof-general2")
240
    (version "4.4")
241
    (source (origin
242
              (method url-fetch)
243
              (uri (string-append
244
                    "https://github.com/ProofGeneral/PG/archive/v"
245
                    version ".tar.gz"))
246
              (file-name (string-append name "-" version ".tar.gz"))
247
              (sha256
248
               (base32
249
                "0zif2fv6mm4pv75nh10q3p37n293495rvx470bx7ma382zc3d8hv"))))
250
    (build-system gnu-build-system)
251
    (native-inputs
252
     `(("which" ,which)
253
       ("emacs" ,emacs-minimal)
254
       ("texinfo" ,texinfo)))
255
    (inputs
256
     `(("host-emacs" ,emacs)
257
       ("perl" ,perl)
258
       ("coq" ,coq)))
259
    (arguments
260
     `(#:tests? #f  ; no check target
261
       #:make-flags (list (string-append "PREFIX=" %output)
262
                          (string-append "DEST_PREFIX=" %output)
263
                          "-j1")
264
       #:modules ((guix build gnu-build-system)
265
                  (guix build utils)
266
                  (guix build emacs-utils))
267
       #:imported-modules (,@%gnu-build-system-modules
268
                           (guix build emacs-utils))
269
       #:phases
270
       (modify-phases %standard-phases
271
         (delete 'configure)
272
         (add-after 'unpack 'disable-byte-compile-error-on-warn
273
                    (lambda _
274
                      (substitute* "Makefile"
275
                        (("\\(setq byte-compile-error-on-warn t\\)")
276
                         "(setq byte-compile-error-on-warn nil)"))
277
                      #t))
278
         (add-after 'unpack 'patch-hardcoded-paths
279
                    (lambda* (#:key inputs outputs #:allow-other-keys)
280
                      (let ((out   (assoc-ref outputs "out"))
281
                            (coq   (assoc-ref inputs "coq"))
282
                            (emacs (assoc-ref inputs "host-emacs")))
283
                        (define (coq-prog name)
284
                          (string-append coq "/bin/" name))
285
                        (substitute* "pgshell/pgshell.el"
286
                          (("/bin/sh") (which "sh")))
287
                        ;(emacs-substitute-variables "coq/coq.el"
288
                        ;  ("coq-prog-name"           (coq-prog "coqtop"))
289
                        ;  ("coq-compiler"            (coq-prog "coqc"))
290
                        ;  ("coq-dependency-analyzer" (coq-prog "coqdep")))
291
                        (substitute* "Makefile"
292
                          (("/sbin/install-info") "install-info"))
293
                        (substitute* "bin/proofgeneral"
294
                          (("^PGHOMEDEFAULT=.*" all)
295
                           (string-append all
296
                                          "PGHOME=$PGHOMEDEFAULT\n"
297
                                          "EMACS=" emacs "/bin/emacs")))
298
                        #t))))))
299
         ;(add-after 'unpack 'clean
300
         ;           (lambda _
301
         ;             ;; Delete the pre-compiled elc files for Emacs 23.
302
         ;             (zero? (system* "make" "clean"))))
303
         ;(add-after 'install 'install-doc
304
         ;           (lambda* (#:key make-flags #:allow-other-keys)
305
         ;             ;; XXX FIXME avoid building/installing pdf files,
306
         ;             ;; due to unresolved errors building them.
307
         ;             (substitute* "Makefile"
308
         ;               ((" [^ ]*\\.pdf") ""))
309
         ;             (zero? (apply system* "make" "install-doc"
310
         ;                           make-flags)))))))
311
    (home-page "http://proofgeneral.inf.ed.ac.uk/")
312
    (synopsis "Generic front-end for proof assistants based on Emacs")
313
    (description
314
     "Proof General is a major mode to turn Emacs into an interactive proof
315
assistant to write formal mathematical proofs using a variety of theorem
316
provers.")
317
    (license license:gpl2+)))
318
319
(define-public ocaml-findlib-fix
320
  (package
321
    (inherit ocaml-findlib)
322
    (native-inputs
323
     `(("camlp4" ,camlp4)
324
       ("ocaml" ,ocaml-fix)
325
       ("m4" ,m4)))))
326
327
(define-public ocaml-build
328
  (package
329
    (name "ocaml-build")
330
    (version "0.11.0")
331
    (source (origin
332
              (method url-fetch)
333
              (uri (string-append "https://github.com/ocaml/ocamlbuild/archive/"
334
                                  version ".tar.gz"))
335
              (file-name (string-append name "-" version ".tar.gz"))
336
              (sha256
337
               (base32
338
                "1vh30731gv1brr4ljfzd6m5lni44ifyb1w8hwir81ff9874fs5qp"))))
339
    (build-system gnu-build-system)
340
    (arguments
341
     `(#:test-target "test"
342
       #:tests? #f; FIXME: tests fail to find Findlib
343
       #:make-flags
344
       (list (string-append "OCAMLBUILD_PREFIX=" (assoc-ref %outputs "out"))
345
             (string-append "OCAMLBUILD_BINDIR=" (assoc-ref %outputs "out") "/bin")
346
             (string-append "OCAMLBUILD_LIBDIR=" (assoc-ref %outputs "out") "/lib")
347
             (string-append "OCAMLBUILD_MANDIR=" (assoc-ref %outputs "out") "/share/man"))
348
       #:phases
349
       (modify-phases %standard-phases
350
         (delete 'configure)
351
         ;(replace 'configure
352
         ;  (lambda* (#:key outputs #:allow-other-keys)
353
         ;    (let ((out (assoc-ref %outputs "out")))
354
         ;      (zero? (system* "make" "-f" "configure.make" "all")))))
355
         (add-before 'build 'findlib-environment
356
           (lambda* (#:key outputs #:allow-other-keys)
357
             (let* ((out (assoc-ref outputs "out")))
358
               (setenv "OCAMLFIND_DESTDIR" (string-append out "/lib/ocaml/site-lib"))
359
               (setenv "OCAMLFIND_LDCONF" "ignore")
360
               #t))))))
361
    (native-inputs
362
     `(("ocaml" ,ocaml-fix)
363
       ("findlib" ,ocaml-findlib-fix)))
364
    (home-page "")
365
    (synopsis "")
366
    (description "")
367
    (license license:lgpl2.1+)))
368
369
(define-public ocaml-menhir-fix
370
  (package
371
    (inherit ocaml-menhir)
372
    (version "20170607")
373
    (name "ocaml-menhir-fix")
374
    (source (origin
375
              (method url-fetch)
376
              (uri (string-append
377
                    "http://gallium.inria.fr/~fpottier/menhir/"
378
                    "menhir-" version ".tar.gz"))
379
              (sha256
380
               (base32
381
                "0qffci9qxgfabzyalx851q994yykl4n9ylr4vbplsm6is1padjh0"))))
382
    (inputs
383
     `(("ocaml" ,ocaml-fix)
384
       ("ocamlbuild" ,ocaml-build)))))
385
386
(define-public compcert
387
  (package
388
    (name "compcert")
389
    (version "3.0.1")
390
    (source (origin
391
              (method url-fetch)
392
              (uri (string-append "http://compcert.inria.fr/release/compcert-"
393
                                  version ".tgz"))
394
              (sha256
395
               (base32
396
                "0dgrj26dzdy4n3s9b5hwc6lm54vans1v4qx9hdp1q8w1qqcdriq9"))))
397
    (build-system gnu-build-system)
398
    (arguments
399
     `(#:phases
400
       (modify-phases %standard-phases
401
         (replace 'configure
402
           (lambda* (#:key outputs #:allow-other-keys)
403
             (zero? (system* "./configure" "x86_64-linux" "-prefix"
404
                             (assoc-ref outputs "out"))))))
405
       #:tests? #f))
406
    (native-inputs
407
     `(("ocaml" ,ocaml)
408
       ("coq" ,coq)))
409
    (inputs
410
     `(("menhir" ,ocaml-menhir-fix)))
411
    (home-page "http://compcert.inria.fr")
412
    (synopsis "Certified C compiler")
413
    (description "CompCert is a certified (with coq) C compiler.  Warning: this
414
package is not free software!")
415
    ;; actually the "INRIA Non-Commercial License Agreement"
416
    ;; a non-free license.
417
    (license (license:non-copyleft "file:///LICENSE"))))
418
419
(define-public cubicle
420
  (package
421
    (name "cubicle")
422
    (version "1.1.1")
423
    (source (origin
424
              (method url-fetch)
425
              (uri (string-append "http://cubicle.lri.fr/cubicle-"
426
                                  version ".tar.gz"))
427
              (sha256
428
               (base32
429
                "1sny9c4fm14k014pk62ibpwbrjjirkx8xmhs9jg7q1hk7y7x3q2h"))))
430
    (build-system gnu-build-system)
431
    (native-inputs
432
     `(("ocaml" ,ocaml)
433
       ("which" ,which)))
434
    (propagated-inputs
435
     `(("z3" ,z3)))
436
    (arguments
437
     `(#:configure-flags (list "--with-z3")
438
       #:tests? #f
439
       #:phases
440
       (modify-phases %standard-phases
441
         (add-before 'configure 'configure-for-release
442
           (lambda _
443
             (substitute* "Makefile.in"
444
               (("SVNREV=") "#SVNREV="))))
445
         (add-before 'configure 'fix-/bin/sh
446
           (lambda _
447
             (substitute* "configure"
448
               (("/bin/sh") (which "sh")))))
449
         (add-before 'configure 'fix-smt-z3wrapper.ml
450
           (lambda _
451
             (substitute* "Makefile.in"
452
               (("\\\\n") "")))))))
453
    (home-page "http://cubicle.lri.fr/")
454
    (synopsis "Model checker for array-based systems")
455
    (description "Cubicle is an open source model checker for verifying safety
456
properties of array-based systems.  This is a syntactically restricted class of
457
parametrized transition systems with states represented as arrays indexed by an
458
arbitrary number of processes.  Cache coherence protocols and mutual exclusion
459
algorithms are typical examples of such systems.")
460
    (license license:asl2.0)))
461
462
(define-public ocaml-c2newspeak
463
  (package
464
    (name "ocaml-c2newspeak")
465
    (version "1")
466
    (source (origin
467
              (method git-fetch)
468
              (uri (git-reference
469
                     (url "https://github.com/airbus-seclab/c2newspeak")
470
                     (commit "6f7adf13fefb7f8d4dc668b8290226e3c6a30063")))
471
              (file-name (string-append name "-" version))
472
              (sha256
473
               (base32
474
                "1apaz0b84865xfba0mxbskbnaq6llqsn3qhy8b0sssbdxzw5w1x4"))))
475
    (build-system ocaml-build-system)
476
    (arguments
477
     `(#:test-target "check"
478
       #:tests? #f
479
       #:phases
480
       (modify-phases %standard-phases
481
         (delete 'configure)
482
         (add-before 'install 'modify-installed-file-list
483
           (lambda _
484
             (substitute* "src/newspeak.Makefile"
485
               (("c2newspeak/typedC.cmi")
486
                "c2newspeak/typedC.cmi c2newspeak/typedC.cmx c2newspeak/typedC.o"))))
487
         (add-after 'install 'install-bin
488
           (lambda* (#:key outputs #:allow-other-keys)
489
             (install-file "bin/c2newspeak" (string-append (assoc-ref outputs "out") "/bin")))))))
490
    (home-page "https://github.com/airbus-seclab/c2newspeak")
491
    (synopsis "")
492
    (description "")
493
    (license license:lgpl2.1+)))
494
495
(define-public ocaml-bincat
496
  (package
497
    (name "ocaml-bincat")
498
    (version "0.6")
499
    (source (origin
500
              (method url-fetch)
501
              (uri (string-append "https://github.com/airbus-seclab/bincat/archive/v"
502
                                  version ".tar.gz"))
503
              (file-name (string-append name "-" version ".tar.gz"))
504
              (sha256
505
               (base32
506
                "1762wrvf7fv16kxfvpblj4b0pwbwny1b39263q4jnqni12474djl"))))
507
    (build-system ocaml-build-system)
508
    (arguments
509
     `(#:tests? #f; some failures for unknown reasons
510
       #:make-flags
511
       (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
512
             "LDCONFIG=true"
513
             (string-append "CFLAGS+=-I " (assoc-ref %build-inputs "ocaml")
514
                            "/lib/ocaml"))
515
       #:phases
516
       (modify-phases %standard-phases
517
         (delete 'configure)
518
         (add-before 'build 'python-path
519
           (lambda _
520
             (setenv "PYTHONPATH" (string-append (getenv "PYTHONPATH")
521
                                                 ":../python"))))
522
         (add-before 'build 'fix-makefile
523
           (lambda _
524
             (substitute* "ocaml/src/Makefile"
525
               (("GITVERSION:=.*") "GITVERSION:=0.6\n")
526
               ;; typedC library is embedded in newspeak.cmxa
527
               (("typedC.cmx") ""))))
528
         (add-before 'check 'fix-test
529
           (lambda _
530
             (setenv "PATH" (string-append (getenv "PATH") ":" (getcwd) "/ocaml/src"))
531
             (chmod "test/eggloader_x86" #o755))))))
532
    (inputs
533
     `(("c2newspeak" ,ocaml-c2newspeak)
534
       ("zarith" ,ocaml-zarith)
535
       ("menhir" ,ocaml-menhir)
536
       ("ocamlgraph" ,ocaml-graph)
537
       ("gmp" ,gmp)))
538
    (native-inputs
539
     `(("python" ,python-2)
540
       ("pytest" ,python2-pytest)
541
       ("sphinx" ,python2-sphinx)
542
       ("nasm" ,nasm)))
543
    (home-page "https://github.com/airbus-seclab/bincat")
544
    (synopsis "")
545
    (description "")
546
    (license license:lgpl2.1+)))
547
548