aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/coq.scm
blob: 09ca4030ea0c09b6388901ff0a95be7a10afa558 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018-2021 Julien Lepiller <julien@lepiller.eu>
;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019 Dan Frumin <dfrumin@cs.ru.nl>
;;; Copyright © 2020 Brett Gilio <brettg@gnu.org>
;;; Copyright © 2020 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
;;; Copyright © 2020 raingloom <raingloom@riseup.net>
;;; Copyright © 2020 Robin Green <greenrd@greenrd.org>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2022 Garek Dyszel <garekdyszel@disroot.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages coq)
  #:use-module (gnu packages)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages base)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages boost)
  #:use-module (gnu packages emacs)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages gawk)
  #:use-module (gnu packages multiprecision)
  #:use-module (gnu packages ocaml)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages python)
  #:use-module (gnu packages rsync)
  #:use-module (gnu packages texinfo)
  #:use-module (guix build-system dune)
  #:use-module (guix build-system gnu)
  #:use-module (guix download)
  #:use-module (guix gexp)
  #:use-module (guix git-download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module ((srfi srfi-1) #:hide (zip)))

(define-public coq-core
  (package
    (name "coq-core")
    (version "8.16.1")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/coq/coq")
             (commit (string-append "V" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "0ljpqhh5lfsim29fcfp2xfcvm3j84pf1mb0gnpdr8vcqqw7mqwpf"))
       (patches (search-patches "coq-fix-envvars.patch"))))
    (native-search-paths
     (list (search-path-specification
            (variable "COQPATH")
            (files (list "lib/ocaml/site-lib/coq/user-contrib"
                         "lib/coq/user-contrib")))
           (search-path-specification
            (variable "COQLIBPATH")
            (files (list "lib/ocaml/site-lib/coq")))
           (search-path-specification
            (variable "COQCORELIB")
            (files (list "lib/ocaml/site-lib/coq-core"))
            (separator #f))))
    (build-system dune-build-system)
    (inputs
     (list gmp ocaml-zarith))
    (native-inputs
     (list ocaml-ounit2 which))
    (arguments
     `(#:package "coq-core"
       #:test-target "."))
    (properties '((upstream-name . "coq"))) ; also for inherited packages
    (home-page "https://coq.inria.fr")
    (synopsis "Proof assistant for higher-order logic")
    (description
     "Coq is a proof assistant for higher-order logic, which allows the
development of computer programs consistent with their formal specification.
It is developed using Objective Caml and Camlp5.")
    ;; The source code is distributed under lgpl2.1.
    ;; Some of the documentation is distributed under opl1.0+.
    (license (list license:lgpl2.1 license:opl1.0+))))

(define-public coq-stdlib
  (package
    (inherit coq-core)
    (name "coq-stdlib")
    (arguments
     `(#:package "coq-stdlib"
       #:test-target "."
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'fix-dune
           (lambda _
             (substitute* "user-contrib/Ltac2/dune"
               (("coq-core.plugins.ltac2")
                (string-join
                  (map (lambda (plugin) (string-append "coq-core.plugins." plugin))
                       '("ltac2" "number_string_notation" "tauto" "cc"
                         "firstorder"))
                  " "))))))))
    (inputs
     (list coq-core gmp ocaml-zarith))
    (native-inputs '())))

(define-public coq
  (package
    (inherit coq-core)
    (name "coq")
    (arguments
     `(#:package "coq"
       #:test-target "."))
    (propagated-inputs
     (list coq-core coq-stdlib))
    (native-inputs '())))

(define-public coq-ide-server
  (package
    (inherit coq)
    (name "coq-ide-server")
    (arguments
     `(#:tests? #f
       #:package "coqide-server"))
    (inputs
     (list coq gmp ocaml-zarith))))

(define-public coq-ide
  (package
    (inherit coq)
    (name "coq-ide")
    (arguments
     `(#:tests? #f
       #:package "coqide"))
    (propagated-inputs
     (list coq coq-ide-server))
    (inputs
     (list lablgtk3 ocaml-lablgtk3-sourceview3))))

(define-public proof-general
  ;; The latest release is from 2016 and there has been more than 450 commits
  ;; since then.
  ;; Commit from 2021-11-25.
  (let ((commit "1b1083e86e0cddc20ff2f1a6b25c7a7eee2edf02")
        (revision "1"))
    (package
      (name "proof-general")
      (version (git-version "4.4" revision commit))
      (source (origin
                (method git-fetch)
                (uri (git-reference
                      (url "https://github.com/ProofGeneral/PG")
                      (commit commit)))
                (file-name (git-file-name name version))
                (sha256
                 (base32
                  "1pnysczhscapgwmvf6ix7f31lf3hnh8h977bfll1m7jlxl9b9c0j"))))
      (build-system gnu-build-system)
      (native-inputs
       `(("emacs" ,emacs-minimal)
         ("texinfo" ,texinfo)))
      (inputs
       (list perl))
      (arguments
       (let ((base-directory "/share/emacs/site-lisp/ProofGeneral"))
         `(#:tests? #f                  ; no check target
           #:make-flags (list (string-append "PREFIX=" %output)
                              (string-append "EMACS=" (assoc-ref %build-inputs "emacs")
                                             "/bin/emacs")
                              (string-append "DEST_PREFIX=" %output)
                              (string-append "ELISP=" %output ,base-directory)
                              (string-append "DEST_ELISP=" %output ,base-directory)
                              (string-append "ELISP_START=" %output ,base-directory))
           #:phases
           (modify-phases %standard-phases
             (delete 'configure)
             (add-after 'unpack 'disable-byte-compile-error-on-warn
               (lambda _
                 (substitute* "Makefile"
                   (("\\(setq byte-compile-error-on-warn t\\)")
                    "(setq byte-compile-error-on-warn nil)"))))
             (add-after 'unpack 'patch-hardcoded-paths
               (lambda _
                 (substitute* "Makefile"
                   (("/sbin/install-info") "install-info"))))
             (add-after 'unpack 'remove-which
               (lambda _
                 (substitute* "Makefile"
                   (("`which perl`") "perl")
                   (("`which bash`") "bash"))))
             (add-after 'unpack 'clean
               (lambda _
                 ;; Delete the pre-compiled elc files for Emacs 23.
                 (invoke "make" "clean")))
             (add-after 'install 'install-doc
               (lambda* (#:key make-flags #:allow-other-keys)
                 ;; XXX FIXME avoid building/installing pdf files,
                 ;; due to unresolved errors building them.
                 (substitute* "Makefile"
                   ((" [^ ]*\\.pdf") ""))
                 (apply invoke "make" "install-doc" make-flags)))
             (add-after 'install 'allow-subfolders-autoloads
               ;; Autoload cookies are present in sub-directories.  A friendly
               ;; wrapper proof-general.el around generic/proof-site.el is
               ;; provided for execution on Emacs start-up.  It serves two
               ;; purposes:
               ;;
               ;; * Setting up the load path when byte-compiling pg.
               ;; * Loading a minimal PG setup on startup (not all of Proof
               ;; General, of course; mostly mode hooks and autoloads).
               ;;
               ;; The renaming to proof-general-autoloads.el is Guix
               ;; specific.
               (lambda* (#:key outputs #:allow-other-keys)
                 (let ((out (assoc-ref outputs "out")))
                   (copy-file "proof-general.el"
                              (string-append out ,base-directory
                                             "/proof-general-autoloads.el")))))))))
      (home-page "https://proofgeneral.github.io/")
      (synopsis "Generic front-end for proof assistants based on Emacs")
      (description
       "Proof General is a major mode to turn Emacs into an interactive proof
assistant to write formal mathematical proofs using a variety of theorem
provers.")
      (license license:gpl3+))))

(define-public coq-flocq
  (package
    (name "coq-flocq")
    (version "4.1.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://gitlab.inria.fr/flocq/flocq.git")
             (commit (string-append "flocq-" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "1yscj1120wch6myakaia03j11qji416v78ylx842d23hrbaqwmw5"))))
    (build-system gnu-build-system)
    (native-inputs
     (list autoconf automake ocaml which coq))
    (arguments
     `(#:configure-flags
       (list (string-append "COQUSERCONTRIB=" (assoc-ref %outputs "out")
                            "/lib/coq/user-contrib"))
       #:phases
       (modify-phases %standard-phases
         (add-before 'configure 'fix-remake
           (lambda _
             (substitute* "remake.cpp"
               (("/bin/sh") (which "sh")))
             #t))
         (replace 'build
           (lambda _
             (invoke "./remake")))
         (replace 'check
           (lambda _
             (invoke "./remake" "check")))
             ;; TODO: requires coq-gappa and coq-interval.
             ;(invoke "./remake" "check-more")
         (replace 'install
           (lambda _
             (invoke "./remake" "install"))))))
    (home-page "https://flocq.gitlabpages.inria.fr")
    (synopsis "Floating-point formalization for the Coq system")
    (description "Flocq (Floats for Coq) is a floating-point formalization for
the Coq system.  It provides a comprehensive library of theorems on a multi-radix
multi-precision arithmetic.  It also supports efficient numerical computations
inside Coq.")
    (license license:lgpl3+)))

(define-public coq-gappa
  (package
    (name "coq-gappa")
    (version "1.5.2")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://gitlab.inria.fr/gappa/coq.git")
             (commit (string-append "gappalib-coq-" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "0l65ah81yj9vabgkwqh47c02qvscvl8nl60gqn1qrs47dx1pi80q"))))
    (build-system gnu-build-system)
    (native-inputs
     (list autoconf
           automake
           ocaml
           which
           coq
           camlp5
           bison
           flex))
    (inputs
     (list gmp mpfr ocaml-zarith boost))
    (propagated-inputs
     (list coq-flocq))
    (arguments
     `(#:configure-flags
       (list (string-append "COQUSERCONTRIB=" (assoc-ref %outputs "out")
                            "/lib/coq/user-contrib")
             (string-append "OCAMLFIND_DESTDIR=" (assoc-ref %outputs "out")
                            "/lib/ocaml/site-lib"))
       #:phases
       (modify-phases %standard-phases
         (add-before 'configure 'fix-remake
           (lambda _
             (substitute* "remake.cpp"
               (("/bin/sh") (which "sh")))
             #t))
         (replace 'build
           (lambda _ (invoke "./remake")))
         ;; FIXME: Figure out why failures occur, and re-enable check phase.
         (delete 'check)
         ;; (replace 'check
         ;;   (lambda _ (invoke "./remake" "check")))
         (replace 'install
           (lambda _ (invoke "./remake" "install"))))))
    (home-page "https://gappa.gitlabpages.inria.fr/")
    (synopsis "Verify and formally prove properties on numerical programs")
    (description "Gappa is a tool intended to help verifying and formally proving
properties on numerical programs dealing with floating-point or fixed-point
arithmetic.  It has been used to write robust floating-point filters for CGAL
and it is used to certify elementary functions in CRlibm.  While Gappa is
intended to be used directly, it can also act as a backend prover for the Why3
software verification plateform or as an automatic tactic for the Coq proof
assistant.")
    (license (list license:gpl2+ license:cecill))));either gpl2+ or cecill

(define-public coq-mathcomp
  (package
    (name "coq-mathcomp")
    (version "1.15.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/math-comp/math-comp")
             (commit (string-append "mathcomp-" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "158zl36zbvi5qx2nqbfnrg00jpgp6hjr5hmls7d8d0421ar6b67i"))))
    (build-system gnu-build-system)
    (native-inputs
     (list ocaml which coq))
    (arguments
     `(#:tests? #f ; No tests.
       #:make-flags (list (string-append "COQLIBINSTALL="
                                         (assoc-ref %outputs "out")
                                         "/lib/coq/user-contrib"))
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)
         (add-before 'build 'chdir
           (lambda _ (chdir "mathcomp") #t)))))
    (home-page "https://math-comp.github.io/")
    (synopsis "Mathematical Components for Coq")
    (description "Mathematical Components for Coq has its origins in the formal
proof of the Four Colour Theorem.  Since then it has grown to cover many areas
of mathematics and has been used for large scale projects like the formal proof
of the Odd Order Theorem.

The library is written using the Ssreflect proof language that is an integral
part of the distribution.")
    (license license:cecill-b)))

(define-public coq-coquelicot
  (package
    (name "coq-coquelicot")
    (version "3.2.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://gitlab.inria.fr/coquelicot/coquelicot.git")
             (commit (string-append "coquelicot-" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "146s5y2xsc7wb43m1pq1n4p14hw99gqbzx0ic3a4naxq16v7cv4w"))))
    (build-system gnu-build-system)
    (native-inputs
     (list autoconf automake ocaml which coq))
    (propagated-inputs
     `(("mathcomp" ,coq-mathcomp)))
    (arguments
     `(#:configure-flags
       (list (string-append "COQUSERCONTRIB=" (assoc-ref %outputs "out")
                            "/lib/coq/user-contrib"))
       #:phases
       (modify-phases %standard-phases
         (add-before 'configure 'fix-remake
           (lambda _
             (substitute* "remake.cpp"
               (("/bin/sh") (which "sh")))
             #t))
         (replace 'build
           (lambda _ (invoke "./remake")))
         (replace 'check
           (lambda _ (invoke "./remake" "check")))
         (replace 'install
           (lambda _ (invoke "./remake" "install"))))))
    (home-page "http://coquelicot.saclay.inria.fr")
    (synopsis "Coq library for Reals")
    (description "Coquelicot is an easier way of writing formulas and theorem
statements, achieved by relying on total functions in place of dependent types
for limits, derivatives, integrals, power series, and so on.  To help with the
proof process, the library comes with a comprehensive set of theorems that cover
not only these notions, but also some extensions such as parametric integrals,
two-dimensional differentiability, asymptotic behaviors.  It also offers some
automations for performing differentiability proofs.  Moreover, Coquelicot is a
conservative extension of Coq's standard library and provides correspondence
theorems between the two libraries.")
    (license license:lgpl3+)))

(define-public coq-bignums
  (package
    (name "coq-bignums")
    (version "8.16.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/coq/bignums")
                     (commit (string-append "V" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "07ndnm7pndmai3a2bkcmwjfjzfaqyq19c5an15hmhgmd0rdy4z8c"))))
    (build-system gnu-build-system)
    (native-inputs
     (list ocaml coq))
    (inputs
     (list camlp5 ocaml-zarith))
    (arguments
     `(#:tests? #f ; No test target.
       #:make-flags
       (list (string-append "COQLIBINSTALL=" (assoc-ref %outputs "out")
                            "/lib/coq/user-contrib")
             (string-append "COQPLUGININSTALL=" (assoc-ref %outputs "out")
                            "/lib/ocaml/site-lib/"))
       #:phases
       (modify-phases %standard-phases
         (delete 'configure))))
    (home-page "https://github.com/coq/bignums")
    (synopsis "Coq library for arbitrary large numbers")
    (description "Bignums is a coq library of arbitrary large numbers.  It
provides BigN, BigZ, BigQ that used to be part of Coq standard library.")
    (license license:lgpl2.1+)))

(define-public coq-interval
  (package
    (name "coq-interval")
    (version "4.5.2")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://gitlab.inria.fr/coqinterval/interval.git")
             (commit (string-append "interval-" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "138vgb0bq6wkygrhkahjgb9spwpzc6x6kkycj2qnf5naxx1z412w"))))
    (build-system gnu-build-system)
    (native-inputs
     (list autoconf automake ocaml which coq))
    (propagated-inputs
     `(("flocq" ,coq-flocq)
       ("bignums" ,coq-bignums)
       ("coquelicot" ,coq-coquelicot)
       ("mathcomp" ,coq-mathcomp)
       ("ocaml-zarith" ,ocaml-zarith)))
    (arguments
     `(#:configure-flags
       (list (string-append "COQUSERCONTRIB=" (assoc-ref %outputs "out")
                            "/lib/coq/user-contrib")
             (string-append "OCAMLFIND_DESTDIR=" (assoc-ref %outputs "out")
                            "/lib/ocaml/site-lib"))
       #:phases
       (modify-phases %standard-phases
         (add-before 'configure 'fix-remake
           (lambda _
             (substitute* "remake.cpp"
               (("/bin/sh") (which "sh")))
             #t))
         (replace 'build
           (lambda _ (invoke "./remake")))
         (replace 'check
           (lambda _ (invoke "./remake" "check")))
         (replace 'install
           (lambda _ (invoke "./remake" "install"))))))
    (home-page "https://coqinterval.gitlabpages.inria.fr/")
    (synopsis "Coq tactics to simplify inequality proofs")
    (description "Interval provides vernacular files containing tactics for
simplifying the proofs of inequalities on expressions of real numbers for the
Coq proof assistant.")
    (license license:cecill-c)))

(define-public coq-autosubst
  ;; Latest commit on that branch, where work on supporting coq 8.6 and
  ;; more recent versions of coq happen.
  (let ((branch "coq86-devel")
        (commit "fa6ef30664511ffa659cbcf3c962715cbee03572"))
    (package
      (name "coq-autosubst")
      (version (git-version "1" branch commit))
      (source (origin
                (method git-fetch)
                (uri (git-reference
                      (url "git://github.com/uds-psl/autosubst")
                      (commit commit)))
                (file-name (git-file-name name version))
                (sha256
                 (base32 "1cl0bp96bk6lplbl7n5c703vd3gvbs5mvf2qrf8q333kkqd7jqq4"))))
      (build-system gnu-build-system)
      (arguments
       `(#:tests? #f
       #:make-flags (list (string-append "COQLIBINSTALL="
                                         (assoc-ref %outputs "out")
                                         "/lib/coq/user-contrib"))
         #:phases
         (modify-phases %standard-phases
           (delete 'configure))))
      (native-inputs
       (list coq))
      (home-page "https://www.ps.uni-saarland.de/autosubst/")
      (synopsis "Coq library for parallel de Bruijn substitutions")
      (description "Formalizing syntactic theories with variable binders is
not easy.  Autosubst is a library for the Coq proof assistant to
automate this process.  Given an inductive definition of syntactic objects in
de Bruijn representation augmented with binding annotations, Autosubst
synthesizes the parallel substitution operation and automatically proves the
basic lemmas about substitutions.  This library contains an automation
tactic that solves equations involving terms and substitutions.  This makes the
usage of substitution lemmas unnecessary.  The tactic is based on our current
work on a decision procedure for the equational theory of an extension of the
sigma-calculus by Abadi et al.  The library is completely written in Coq and
uses Ltac to synthesize the substitution operation.")
      (license license:bsd-3))))

(define-public coq-equations
  (package
    (name "coq-equations")
    (version "1.3")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/mattam82/Coq-Equations")
                    (commit (string-append "v" version "-8.16"))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "08f756vgdd1wklkarg0b93j4n5mhkqm5ixxrhyb23dcv2dwhc8yg"))))
    (build-system gnu-build-system)
    (native-inputs
     (list ocaml coq camlp5))
    (inputs
     (list ocaml-zarith))
    (arguments
     `(#:test-target "test-suite"
       #:make-flags (list (string-append "COQLIBINSTALL="
                                         (assoc-ref %outputs "out")
                                         "/lib/coq/user-contrib")
                          (string-append "COQPLUGININSTALL="
                                         (assoc-ref %outputs "out")
                                         "/lib/ocaml/site-lib/"))
       #:phases
       (modify-phases %standard-phases
         (replace 'configure
           (lambda* (#:key outputs #:allow-other-keys)
             (invoke "sh" "./configure.sh"))))))
    (home-page "https://mattam82.github.io/Coq-Equations/")
    (synopsis "Function definition plugin for Coq")
    (description "Equations provides a notation for writing programs
by dependent pattern-matching and (well-founded) recursion in Coq.  It
compiles everything down to eliminators for inductive types, equality
and accessibility, providing a definitional extension to the Coq
kernel.")
    (license license:lgpl2.1)))

(define-public coq-semantics
  (package
    (name "coq-semantics")
    (version "8.14.0")
    (source
      (origin
        (method git-fetch)
        (uri (git-reference
              (url "https://github.com/coq-community/semantics")
              (commit (string-append "v" version))))
        (modules '((guix build utils)))
        (snippet
         '(substitute* "Makefile.coq.local"
            ;; Num was part of OCaml and now external
            (("-libs nums") "-use-ocamlfind -pkg num -libs num")))
        (file-name (git-file-name name version))
        (sha256
         (base32
          "0ldrp86bfcjpzsb08p45sgs3aczjzr1gksy5dsf7pxapg05pc7ac"))))
    (build-system gnu-build-system)
    (native-inputs
     (list coq ocaml ocamlbuild ocaml-findlib))
    (inputs
     (list ocaml-num))
    (arguments
     `(#:tests? #f                      ;included in Makefile
       #:make-flags (list (string-append "COQLIBINSTALL="
                                         (assoc-ref %outputs "out")
                                         "/lib/coq/user-contrib"))
       #:phases
       (modify-phases %standard-phases
         (delete 'configure))))
    (home-page "https://github.com/coq-community/semantics")
    (synopsis "Survey of semantics styles")
    (description
     "This package provides a survey of programming language semantics styles,
from natural semantics through structural operational, axiomatic, and
denotational semantics, for a miniature example of an imperative programming
language.  Their encoding, the proofs of equivalence of different styles,
abstract interpretation, and the proof of soundess obtained from axiomatic
semantics or abstract interpretation is done in Coq.  The tools can be run
inside Coq, thus making them available for proof by reflection.  Code can also
be extracted and connected to a yacc-based parser, thanks to the use of a
functor parameterized by a module type of strings.  A hand-written parser is
also provided in Coq, without associated proofs.")
    (license license:expat)))

(define-public coq-stdpp
  (package
    (name "coq-stdpp")
    (version "1.7.0")
    (synopsis "Alternative Coq standard library std++")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://gitlab.mpi-sws.org/iris/stdpp.git")
                    (commit (string-append "coq-stdpp-" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0447wbzm23f9rl8byqf6vglasfn6c1wy6cxrrwagqjwsh3i5lx8y"))))
    (build-system gnu-build-system)
    (inputs
     (list coq))
    (arguments
     `(#:tests? #f ; Tests are executed during build phase.
       #:make-flags (list (string-append "COQLIBINSTALL="
                                         (assoc-ref %outputs "out")
                                         "/lib/coq/user-contrib"))
       #:phases
       (modify-phases %standard-phases
         (delete 'configure))))
    (description "This project contains an extended \"Standard Library\" for
Coq called coq-std++.  The key features are:
@itemize
@item Great number of definitions and lemmas for common data structures such
as lists, finite maps, finite sets, and finite multisets.

@item Type classes for common notations (like ∅, ∪, and Haskell-style monad
notations) so that these can be overloaded for different data structures.

@item It uses type classes to keep track of common properties of types, like
it having decidable equality or being countable or finite.

@item Most data structures are represented in canonical ways so that Leibniz
equality can be used as much as possible (for example, for maps we have m1 =
m2 iff ∀ i, m1 !! i = m2 !! i).  On top of that, the library provides setoid
instances for most types and operations.

@item Various tactics for common tasks, like an ssreflect inspired done tactic
for finishing trivial goals, a simple breadth-first solver naive_solver, an
equality simplifier simplify_eq, a solver solve_proper for proving
compatibility of functions with respect to relations, and a solver set_solver
for goals involving set operations.

@item The library is dependency- and axiom-free.
@end itemize")
    (home-page "https://gitlab.mpi-sws.org/iris/stdpp")
    (license license:bsd-3)))

(define-public coq-mathcomp-finmap
  (package
    (name "coq-mathcomp-finmap")
    (version "1.5.2")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/math-comp/finmap")
                    (commit version)))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "1k72wpp15xa5ag358jl8a71gschng0bgbaqjx0l5a0in6x5adafh"))))
    (build-system gnu-build-system)
    (arguments
     `(;; No tests supplied in Makefile.common.
       ;; The project doesn't appear to have plans to include tests in
       ;; the future.
       #:tests? #f
       #:make-flags (list (string-append "COQLIBINSTALL="
                                         (assoc-ref %outputs "out")
                                         "/lib/coq/user-contrib"))
       #:phases (modify-phases %standard-phases
                  (delete 'configure))))
    (inputs (list coq coq-stdlib coq-mathcomp which))
    (synopsis "Finite sets and finite types for coq-mathcomp")
    (description
     "This library is an extension of coq-mathcomp which supports finite sets
and finite maps on choicetypes (rather than finite types).  This includes
support for functions with finite support and multisets.  The library also
contains a generic order and set library, which will eventually be used to
subsume notations for finite sets.")
    (home-page "https://math-comp.github.io/")
    (license license:cecill-b)))

(define-public coq-mathcomp-bigenough
  (package
    (name "coq-mathcomp-bigenough")
    (version "1.0.1")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/math-comp/bigenough")
                    (commit version)))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "02f4dv4rz72liciwxb2k7acwx6lgqz4381mqyq5854p3nbyn06aw"))))
    (build-system gnu-build-system)
    (arguments
     `(;; No references to tests in Makefile.common.
       ;; It doesn't appear as though tests will be included
       ;; by the packaged project in the future.
       #:tests? #f
       #:make-flags ,#~(list (string-append "COQBIN="
                                            #$(this-package-input "coq-core")
                                            "/bin/")
                             (string-append "COQMF_COQLIB="
                                            (assoc-ref %outputs "out")
                                            "/lib/ocaml/site-lib/coq")
                             (string-append "COQLIBINSTALL="
                                            (assoc-ref %outputs "out")
                                            "/lib/coq/user-contrib"))
       #:phases (modify-phases %standard-phases
                  (delete 'configure))))
    (propagated-inputs (list coq coq-core coq-mathcomp which))
    (home-page "https://math-comp.github.io/")
    (synopsis "Small library to do epsilon - N reasoning")
    (description
     "The package is used for reasoning with big enough objects (mostly
natural numbers).  This package is essentially for backward compatibility
purposes as @code{bigenough} will be subsumed by the near tactics.  The
formalization is based on the Mathematical Components library.")
    (license license:cecill-b)))
lacements and ;; solid arrows represent dependencies: ;; ;; P1 ·············> P1R ;; |\__________________. ;; v v ;; P2 ·············> P2R ;; | ;; v ;; P3 ;; ;; We want to make sure that: ;; grafts(P3) = (P1,P1R) + (P2, grafted(P2R, (P1,P1R))) ;; where: ;; (A,B) is a graft to replace A by B ;; grafted(DRV,G) denoted DRV with graft G applied (let* ((p1r (dummy-package "P1" (build-system trivial-build-system) (arguments `(#:guile ,%bootstrap-guile #:builder (let ((out (assoc-ref %outputs "out"))) (mkdir out) (call-with-output-file (string-append out "/replacement") (const #t))))))) (p1 (package (inherit p1r) (name "p1") (replacement p1r) (arguments `(#:guile ,%bootstrap-guile #:builder (begin (mkdir (assoc-ref %outputs "out")) #t))))) (p2r (dummy-package "P2" (build-system trivial-build-system) (inputs (list p1)) (arguments `(#:guile ,%bootstrap-guile #:builder (let ((out (assoc-ref %outputs "out"))) (mkdir out) (chdir out) (symlink (assoc-ref %build-inputs "p1") "p1") (call-with-output-file (string-append out "/replacement") (const #t))))))) (p2 (package (inherit p2r) (name "p2") (replacement p2r) (arguments `(#:guile ,%bootstrap-guile #:builder (let ((out (assoc-ref %outputs "out"))) (mkdir out) (chdir out) (symlink (assoc-ref %build-inputs "p1") "p1") #t))))) (p3 (dummy-package "p3" (build-system trivial-build-system) (inputs (list p2)) (arguments `(#:guile ,%bootstrap-guile #:builder (let ((out (assoc-ref %outputs "out"))) (mkdir out) (chdir out) (symlink (assoc-ref %build-inputs "p2") "p2") #t)))))) (lset= equal? (package-grafts %store p3) (list (graft (origin (package-derivation %store p1 #:graft? #f)) (replacement (package-derivation %store p1r))) (graft (origin (package-derivation %store p2 #:graft? #f)) (replacement (package-derivation %store p2r #:graft? #t))))))) ;;; XXX: Nowadays 'graft-derivation' needs to build derivations beforehand to ;;; find out about their run-time dependencies, so this test is no longer ;;; applicable since it would trigger a full rebuild. ;; ;; (test-assert "package-derivation, indirect grafts" ;; (let* ((new (dummy-package "dep" ;; (arguments '(#:implicit-inputs? #f)))) ;; (dep (package (inherit new) (version "0.0"))) ;; (dep* (package (inherit dep) (replacement new))) ;; (dummy (dummy-package "dummy" ;; (arguments '(#:implicit-inputs? #f)) ;; (inputs `(("dep" ,dep*))))) ;; (guile (package-derivation %store (canonical-package guile-2.0) ;; #:graft? #f))) ;; (equal? (package-derivation %store dummy) ;; (graft-derivation %store ;; (package-derivation %store dummy #:graft? #f) ;; (package-grafts %store dummy) ;; ;; Use the same Guile as 'package-derivation'. ;; #:guile guile)))) (test-equal "package->bag" (parameterize ((%current-system "foo86-hurd")) `("foo86-hurd" #f (,(package-source gnu-make)) (,(canonical-package glibc)) (,(canonical-package coreutils)))) (let ((bag (package->bag gnu-make "foo86-hurd"))) (list (bag-system bag) (bag-target bag) (assoc-ref (bag-build-inputs bag) "source") (assoc-ref (bag-build-inputs bag) "libc") (assoc-ref (bag-build-inputs bag) "coreutils")))) (test-assert "package->bag, sensitivity to %current-target-system" ;; https://bugs.gnu.org/41713 (let* ((lower (lambda* (name #:key system target inputs native-inputs #:allow-other-keys) (and (not target) (bag (name name) (system system) (target target) (build-inputs native-inputs) (host-inputs inputs) (build (lambda* (name inputs #:key system target #:allow-other-keys) (gexp->derivation "foo" #~(mkdir #$output)))))))) (bs (build-system (name 'build-system-without-cross-compilation) (description "Does not support cross compilation.") (lower lower))) (dep (dummy-package "dep" (build-system bs))) (pkg (dummy-package "example" (native-inputs (list dep)))) (do-not-build (lambda (continue store lst . _) lst))) (equal? (with-build-handler do-not-build (parameterize ((%current-target-system "powerpc64le-linux-gnu") (%graft? #t)) (package-cross-derivation %store pkg (%current-target-system) #:graft? #t))) (with-build-handler do-not-build (package-cross-derivation %store (package (inherit pkg)) "powerpc64le-linux-gnu" #:graft? #t))))) (test-equal "package->bag, cross-compilation" `(,(%current-system) "foo86-hurd" (,(package-source gnu-make)) (,(canonical-package glibc)) (,(canonical-package coreutils))) (let ((bag (package->bag gnu-make (%current-system) "foo86-hurd"))) (list (bag-system bag) (bag-target bag) (assoc-ref (bag-build-inputs bag) "source") (assoc-ref (bag-build-inputs bag) "libc") (assoc-ref (bag-build-inputs bag) "coreutils")))) (test-assert "package->bag, propagated inputs" (let* ((dep (dummy-package "dep")) (prop (dummy-package "prop" (propagated-inputs (list dep)))) (dummy (dummy-package "dummy" (inputs (list prop)))) (inputs (bag-transitive-inputs (package->bag dummy #:graft? #f)))) (match (assoc "dep" inputs) (("dep" package) (eq? package dep))))) (test-assert "package->bag, sensitivity to %current-system" (let* ((dep (dummy-package "dep" (propagated-inputs (if (string=? (%current-system) "i586-gnu") `(("libxml2" ,libxml2)) '())))) (pkg (dummy-package "foo" (native-inputs (list dep)))) (bag (package->bag pkg (%current-system) "i586-gnu"))) (equal? (parameterize ((%current-system "x86_64-linux")) (bag-transitive-inputs bag)) (parameterize ((%current-system "i586-gnu")) (bag-transitive-inputs bag))))) (test-assert "package->bag, sensitivity to %current-target-system" (let* ((dep (dummy-package "dep" (propagated-inputs (if (%current-target-system) `(("libxml2" ,libxml2)) '())))) (pkg (dummy-package "foo" (native-inputs (list dep)))) (bag (package->bag pkg (%current-system) "foo86-hurd"))) (equal? (parameterize ((%current-target-system "foo64-gnu")) (bag-transitive-inputs bag)) (parameterize ((%current-target-system #f)) (bag-transitive-inputs bag))))) (test-assertm "bag->derivation" (parameterize ((%graft? #f)) (let ((bag (package->bag gnu-make)) (drv (package-derivation %store gnu-make))) (parameterize ((%current-system "foox86-hurd")) ;should have no effect (mlet %store-monad ((bag-drv (bag->derivation bag))) (return (equal? drv bag-drv))))))) (test-assert "bag->derivation, cross-compilation" (parameterize ((%graft? #f)) (let* ((target "mips64el-linux-gnu") (bag (package->bag gnu-make (%current-system) target)) (drv (package-cross-derivation %store gnu-make target))) (parameterize ((%current-system "foox86-hurd") ;should have no effect (%current-target-system "foo64-linux-gnu")) (mlet %store-monad ((bag-drv (bag->derivation bag))) (return (equal? drv bag-drv))))))) (when (or (not (network-reachable?)) (shebang-too-long?)) (test-skip 1)) (test-assert "GNU Make, bootstrap" ;; GNU-MAKE-FOR-TESTS can be built cheaply; we choose it here so that the ;; test doesn't last for too long. (let ((gnu-make gnu-make-for-tests)) (and (package? gnu-make) (or (location? (package-location gnu-make)) (not (package-location gnu-make))) (let* ((drv (package-derivation %store gnu-make)) (out (derivation->output-path drv))) (and (build-derivations %store (list drv)) (file-exists? (string-append out "/bin/make"))))))) (test-equal "package-mapping" 42 (let* ((dep (dummy-package "chbouib" (native-inputs `(("x" ,grep))))) (p0 (dummy-package "example" (source 77) (inputs `(("foo" ,coreutils) ("bar" ,grep) ("baz" ,dep))))) (transform (lambda (p) (package (inherit p) (source 42)))) (rewrite (package-mapping transform)) (p1 (rewrite p0)) (bag0 (package->bag p0)) (bag1 (package->bag p1))) (and (eq? p1 (rewrite p0)) (eqv? 42 (package-source p1)) ;; Implicit inputs should be left unchanged (skip "source", "foo", ;; "bar", and "baz" in this comparison). (equal? (drop (bag-direct-inputs bag0) 4) (drop (bag-direct-inputs bag1) 4)) (match (package-inputs p1) ((("foo" dep1) ("bar" dep2) ("baz" dep3)) (and (eq? dep1 (rewrite coreutils)) ;memoization (eq? dep2 (rewrite grep)) (eq? dep3 (rewrite dep)) (eqv? 42 (package-source dep1) (package-source dep2) (package-source dep3)) (match (package-native-inputs dep3) ((("x" dep)) (and (eq? dep (rewrite grep)) (package-source dep)))))))))) (test-equal "package-mapping, deep" '(42) (let* ((p0 (dummy-package "example" (inputs `(("foo" ,coreutils) ("bar" ,grep))))) (transform (lambda (p) (package (inherit p) (source 42)))) (rewrite (package-mapping transform #:deep? #t)) (p1 (rewrite p0)) (bag (package->bag p1))) (and (eq? p1 (rewrite p0)) (match (bag-direct-inputs bag) ((("source" 42) ("foo" dep1) ("bar" dep2) rest ..1) (and (eq? dep1 (rewrite coreutils)) ;memoization (eq? dep2 (rewrite grep)) (= 42 (package-source dep1)) (= 42 (package-source dep2)) ;; Check that implicit inputs of P0 also got rewritten. (delete-duplicates (map (match-lambda ((_ package . _) (package-source package))) rest)))))))) (test-assert "package-input-rewriting" (let* ((dep (dummy-package "chbouib" (native-inputs `(("x" ,grep))))) (p0 (dummy-package "example" (inputs `(("foo" ,coreutils) ("bar" ,grep) ("baz" ,dep))))) (rewrite (package-input-rewriting `((,coreutils . ,sed) (,grep . ,findutils)) (cut string-append "r-" <>) #:deep? #f)) (p1 (rewrite p0)) (p2 (rewrite p0))) (and (not (eq? p1 p0)) (eq? p1 p2) ;memoization (string=? "r-example" (package-name p1)) (match (package-inputs p1) ((("foo" dep1) ("bar" dep2) ("baz" dep3)) (and (eq? dep1 sed) (eq? dep2 findutils) (string=? (package-name dep3) "r-chbouib") (eq? dep3 (rewrite dep)) ;memoization (match (package-native-inputs dep3) ((("x" dep)) (eq? dep findutils)))))) ;; Make sure implicit inputs were left unchanged. (equal? (drop (bag-direct-inputs (package->bag p1)) 3) (drop (bag-direct-inputs (package->bag p0)) 3))))) (test-eq "package-input-rewriting, deep" (derivation-file-name (package-derivation %store sed)) (let* ((p0 (dummy-package "chbouib" (build-system python-build-system) (arguments `(#:python ,python)))) (rewrite (package-input-rewriting `((,python . ,sed)))) (p1 (rewrite p0))) (match (bag-direct-inputs (package->bag p1)) ((("python" python) _ ...) (derivation-file-name (package-derivation %store python)))))) (test-assert "package-input-rewriting, recursive" (let* ((dep (dummy-package "dep" (native-inputs (list grep)))) (p0 (dummy-package "example1" (inputs (list dep grep)))) (p1 (dummy-package "example2" (inputs (list dep grep)))) (replacements `((,grep . ,findutils) (,p0 . ,p1))) (rewrite (package-input-rewriting replacements)) (rewrite/recursive (package-input-rewriting replacements #:recursive? #t)) (p2 (rewrite p0)) (p3 (rewrite/recursive p0))) (and (string=? (package-name p2) "example2") ;; Here P0 is replaced by P1, but P1 itself is kept unchanged. (match (package-inputs p2) ((("dep" dep1) ("grep" dep2)) (and (match (package-native-inputs dep1) ((("grep" x)) (eq? x grep))) (eq? dep2 grep)))) ;; Here P0 is replaced by P1, and in addition references to GREP in ;; P1 and its dependencies are also replaced by FINDUTILS. (string=? (package-name p3) "example2") (match (package-inputs p3) ((("dep" dep1) ("grep" dep2)) (and (match (package-native-inputs dep1) ((("grep" x)) (string=? (package-full-name x) (package-full-name findutils)))) (string=? (package-full-name dep2) (package-full-name findutils)))))))) (test-assert "package-input-rewriting/spec" (let* ((dep (dummy-package "chbouib" (native-inputs `(("x" ,grep))))) (p0 (dummy-package "example" (inputs `(("foo" ,coreutils) ("bar" ,grep) ("baz" ,dep))))) (rewrite (package-input-rewriting/spec `(("coreutils" . ,(const sed)) ("grep" . ,(const findutils))) #:deep? #f)) (p1 (rewrite p0)) (p2 (rewrite p0))) (and (not (eq? p1 p0)) (eq? p1 p2) ;memoization (string=? "example" (package-name p1)) (match (package-inputs p1) ((("foo" dep1) ("bar" dep2) ("baz" dep3)) (and (string=? (package-full-name dep1) (package-full-name sed)) (string=? (package-full-name dep2) (package-full-name findutils)) (string=? (package-name dep3) "chbouib") (eq? dep3 (rewrite dep)) ;memoization (match (package-native-inputs dep3) ((("x" dep)) (string=? (package-full-name dep) (package-full-name findutils))))))) ;; Make sure implicit inputs were left unchanged. (equal? (drop (bag-direct-inputs (package->bag p1)) 3) (drop (bag-direct-inputs (package->bag p0)) 3))))) (test-assert "package-input-rewriting/spec, partial match" (let* ((dep (dummy-package "chbouib" (version "1") (native-inputs `(("x" ,grep))))) (p0 (dummy-package "example" (inputs `(("foo" ,coreutils) ("bar" ,dep))))) (rewrite (package-input-rewriting/spec `(("chbouib@123" . ,(const sed)) ;not matched ("grep" . ,(const findutils))) #:deep? #f)) (p1 (rewrite p0))) (and (not (eq? p1 p0)) (string=? "example" (package-name p1)) (match (package-inputs p1) ((("foo" dep1) ("bar" dep2)) (and (string=? (package-full-name dep1) (package-full-name coreutils)) (eq? dep2 (rewrite dep)) ;memoization (match (package-native-inputs dep2) ((("x" dep)) (string=? (package-full-name dep) (package-full-name findutils)))))))))) (test-assert "package-input-rewriting/spec, deep" (let* ((dep (dummy-package "chbouib")) (p0 (dummy-package "example" (build-system gnu-build-system) (inputs `(("dep" ,dep))))) (rewrite (package-input-rewriting/spec `(("tar" . ,(const sed)) ("gzip" . ,(const findutils))))) (p1 (rewrite p0)) (p2 (rewrite p0))) (and (not (eq? p1 p0)) (eq? p1 p2) ;memoization (string=? "example" (package-name p1)) (match (package-inputs p1) ((("dep" dep1)) (and (string=? (package-full-name dep1) (package-full-name dep)) (eq? dep1 (rewrite dep))))) ;memoization ;; Make sure implicit inputs were replaced. (match (bag-direct-inputs (package->bag p1)) ((("dep" dep1) ("tar" tar) ("gzip" gzip) _ ...) (and (eq? dep1 (rewrite dep)) (string=? (package-full-name tar) (package-full-name sed)) (string=? (package-full-name gzip) (package-full-name findutils)))))))) (test-assert "package-input-rewriting/spec, no duplicates" ;; Ensure that deep input rewriting does not forget implicit inputs. Doing ;; so could lead to duplicates in a package's inputs: in the example below, ;; P0's transitive inputs would contain one rewritten "python" and one ;; original "python". These two "python" packages are thus not 'eq?' but ;; they lower to the same derivation. See <https://bugs.gnu.org/42156>, ;; which can be reproduced by passing #:deep? #f. (let* ((dep0 (dummy-package "dep0" (build-system trivial-build-system) (propagated-inputs `(("python" ,python))))) (p0 (dummy-package "chbouib" (build-system python-build-system) (arguments `(#:python ,python)) (inputs `(("dep0" ,dep0))))) (rewrite (package-input-rewriting/spec '() #:deep? #t)) (p1 (rewrite p0)) (bag1 (package->bag p1)) (pythons (filter-map (match-lambda (("python" python) python) (_ #f)) (bag-transitive-inputs bag1)))) (match (delete-duplicates pythons eq?) ((p) (eq? p (rewrite python)))))) (test-assert "package-input-rewriting/spec, hidden package" ;; Hidden packages are not subject to rewriting. (let* ((python (hidden-package python)) (p0 (dummy-package "chbouib" (build-system trivial-build-system) (inputs (list python)))) (rewrite (package-input-rewriting/spec `(("python" . ,(const sed))) #:deep? #t)) (p1 (rewrite p0)) (bag1 (package->bag p1)) (pythons (filter-map (match-lambda (("python" python) python) (_ #f)) (bag-transitive-inputs bag1)))) (match (delete-duplicates pythons eq?) ((p) (eq? p python))))) (test-assert "package-input-rewriting/spec, replace hidden package" ;; Rewrite hidden packages when requested. (let* ((python (hidden-package python)) (p0 (dummy-package "chbouib" (build-system trivial-build-system) (inputs (list python)))) (rewrite (package-input-rewriting/spec `(("python" . ,(const sed))) #:replace-hidden? #t)) (p1 (rewrite p0))) (match (package-inputs p1) ((("python" python)) (and (string=? (package-full-name python) (package-full-name sed))))))) (test-equal "package-input-rewriting/spec, graft" (derivation-file-name (package-derivation %store sed)) ;; Make sure replacements are rewritten. (let* ((dep0 (dummy-package "dep" (version "1") (build-system trivial-build-system) (inputs `(("coreutils" ,coreutils))))) (dep1 (dummy-package "dep" (version "0") (build-system trivial-build-system) (replacement dep0))) (p0 (dummy-package "p" (build-system trivial-build-system) (inputs `(("dep" ,dep1))))) (rewrite (package-input-rewriting/spec `(("coreutils" . ,(const sed))))) (p1 (rewrite p0))) (match (package-inputs p1) ((("dep" dep)) (match (package-inputs (package-replacement dep)) ((("coreutils" coreutils)) ;; COREUTILS is not 'eq?' to SED, so the most reliable way to check ;; for equality is to lower to a derivation. (derivation-file-name (package-derivation %store coreutils)))))))) (test-assert "package-with-c-toolchain" (let* ((dep (dummy-package "chbouib" (build-system gnu-build-system) (native-inputs `(("x" ,grep))))) (p0 (dummy-package "thingie" (build-system gnu-build-system) (inputs `(("foo" ,grep) ("bar" ,dep))))) (tc (dummy-package "my-toolchain")) (p1 (package-with-c-toolchain p0 `(("toolchain" ,tc))))) (define toolchain-packages '("gcc" "binutils" "glibc" "ld-wrapper")) (match (bag-build-inputs (package->bag p1)) ((("foo" foo) ("bar" bar) (_ (= package-name packages) . _) ...) (and (not (any (cut member <> packages) toolchain-packages)) (member "my-toolchain" packages) (eq? foo grep) (eq? bar dep)))))) (test-assert "package-input-rewriting/spec, identity" ;; Make sure that 'package-input-rewriting/spec' doesn't gratuitously ;; introduce variants. In this case, the LIBFFI propagated input should not ;; be duplicated when passing GOBJECT through REWRITE. ;; See <https://issues.guix.gnu.org/43890>. (let* ((libffi (dummy-package "libffi" (build-system trivial-build-system))) (glib (dummy-package "glib" (build-system trivial-build-system) (propagated-inputs (list libffi)))) (gobject (dummy-package "gobject-introspection" (build-system trivial-build-system) (inputs (list glib)) (propagated-inputs (list libffi)))) (rewrite (package-input-rewriting/spec `(("glib" . ,identity))))) (and (= (length (package-transitive-inputs gobject)) (length (package-transitive-inputs (rewrite gobject)))) (string=? (derivation-file-name (package-derivation %store (rewrite gobject))) (derivation-file-name (package-derivation %store gobject)))))) (test-assert "package-input-rewriting, identity" ;; Similar to the test above, but with 'package-input-rewriting'. ;; See <https://issues.guix.gnu.org/43890>. (let* ((libffi (dummy-package "libffi" (build-system trivial-build-system))) (glib (dummy-package "glib" (build-system trivial-build-system) (propagated-inputs (list libffi)))) (gobject (dummy-package "gobject-introspection" (build-system trivial-build-system) (inputs (list glib)) (propagated-inputs (list libffi)))) (rewrite (package-input-rewriting `((,glib . ,glib))))) (and (= (length (package-transitive-inputs gobject)) (length (package-transitive-inputs (rewrite gobject)))) (string=? (derivation-file-name (package-derivation %store (rewrite gobject))) (derivation-file-name (package-derivation %store gobject)))))) (test-equal "package-patched-vulnerabilities" '(("CVE-2015-1234") ("CVE-2016-1234" "CVE-2018-4567") ()) (let ((p1 (dummy-package "pi" (source (dummy-origin (patches (list "/a/b/pi-CVE-2015-1234.patch")))))) (p2 (dummy-package "pi" (source (dummy-origin (patches (list "/a/b/pi-CVE-2016-1234-CVE-2018-4567.patch")))))) (p3 (dummy-package "pi" (source (dummy-origin))))) (map package-patched-vulnerabilities (list p1 p2 p3)))) (test-eq "fold-packages" hello (fold-packages (lambda (p r) (if (string=? (package-name p) "hello") p r)) #f)) (test-assert "fold-packages, hidden package" ;; There are two public variables providing "guile@2.0" ('guile-final' in ;; commencement.scm and 'guile-2.0' in guile.scm), but only the latter ;; should show up. (match (fold-packages (lambda (p r) (if (and (string=? (package-name p) "guile") (string-prefix? "2.0" (package-version p))) (cons p r) r)) '()) ((one) (eq? one guile-2.0)))) (test-assert "fold-available-packages with/without cache" (let () (define no-cache (fold-available-packages (lambda* (name version result #:rest rest) (cons (cons* name version rest) result)) '())) (define from-cache (call-with-temporary-directory (lambda (cache) (generate-package-cache cache) (mock ((guix describe) current-profile (const cache)) (mock ((gnu packages) cache-is-authoritative? (const #t)) (fold-available-packages (lambda* (name version result #:rest rest) (cons (cons* name version rest) result)) '())))))) (define (list->set* lst) ;; Return two values: LST represented as a set and the list of ;; duplicates in LST. (let loop ((lst lst) (duplicates '()) (seen (set))) (match lst (() (values seen duplicates)) ((head . tail) (if (set-contains? seen head) (loop tail (cons head duplicates) seen) (loop tail duplicates (set-insert head seen))))))) ;; Compare FROM-CACHE and NO-CACHE but avoid 'lset=', which exhibits ;; exponential behavior. (let ((set1 duplicates1 (list->set* from-cache)) (set2 duplicates2 (list->set* no-cache))) ;; For easier debugging. (pk 'from-cache-duplicates: duplicates1) (pk 'no-cache-duplicates: duplicates2) (and (null? duplicates1) (null? duplicates2) (every (cut set-contains? set1 <>) no-cache) (every (cut set-contains? set2 <>) from-cache))))) (test-assert "find-packages-by-name" (match (find-packages-by-name "hello") (((? (cut eq? hello <>))) #t) (wrong (pk 'find-packages-by-name wrong #f)))) (test-assert "find-packages-by-name with version" (match (find-packages-by-name "hello" (package-version hello)) (((? (cut eq? hello <>))) #t) (wrong (pk 'find-packages-by-name wrong #f)))) (test-equal "find-packages-by-name with cache" (find-packages-by-name "guile") (call-with-temporary-directory (lambda (cache) (generate-package-cache cache) (mock ((guix describe) current-profile (const cache)) (mock ((gnu packages) cache-is-authoritative? (const #t)) (find-packages-by-name "guile")))))) (test-equal "find-packages-by-name + version, with cache" (find-packages-by-name "guile" "2") (call-with-temporary-directory (lambda (cache) (generate-package-cache cache) (mock ((guix describe) current-profile (const cache)) (mock ((gnu packages) cache-is-authoritative? (const #t)) (find-packages-by-name "guile" "2")))))) (test-assert "--search-paths with pattern" ;; Make sure 'guix package --search-paths' correctly reports environment ;; variables when file patterns are used (in particular, it must follow ;; symlinks when looking for 'catalog.xml'.) To do that, we rely on the ;; libxml2 package specification, which contains such a definition. (let* ((p1 (package (name "foo") (version "0") (source #f) (build-system trivial-build-system) (arguments `(#:guile ,%bootstrap-guile #:modules ((guix build utils)) #:builder (begin (use-modules (guix build utils)) (let ((out (assoc-ref %outputs "out"))) (mkdir-p (string-append out "/xml/bar/baz")) (call-with-output-file (string-append out "/xml/bar/baz/catalog.xml") (lambda (port) (display "xml? wat?!" port))) #t)))) (synopsis #f) (description #f) (home-page #f) (license #f))) (p2 (package ;; Provide a fake libxml2 to avoid building the real one. This ;; is OK because 'guix package' gets search path specifications ;; from the same-named package found in the distro. (name "libxml2") (version "0.0.0") (source #f) (build-system trivial-build-system) (arguments `(#:guile ,%bootstrap-guile #:builder (begin (mkdir (assoc-ref %outputs "out")) #t))) (native-search-paths (package-native-search-paths libxml2)) (synopsis #f) (description #f) (home-page #f) (license #f))) (prof (run-with-store %store (profile-derivation (manifest (map package->manifest-entry (list p1 p2))) #:hooks '() #:locales? #f) #:guile-for-build (%guile-for-build)))) (build-derivations %store (list prof)) (string-match (format #f "^export XML_CATALOG_FILES=\"~a/xml/+bar/baz/catalog\\.xml\"\n" (regexp-quote (derivation->output-path prof))) (with-output-to-string (lambda () (guix-package "-p" (derivation->output-path prof) "--search-paths")))))) (test-assert "--search-paths with single-item search path" ;; Make sure 'guix package --search-paths' correctly reports environment ;; variables for things like 'GIT_SSL_CAINFO' that have #f as their ;; separator, meaning that the first match wins. (let* ((p1 (dummy-package "foo" (build-system trivial-build-system) (arguments `(#:guile ,%bootstrap-guile #:modules ((guix build utils)) #:builder (begin (use-modules (guix build utils)) (let ((out (assoc-ref %outputs "out"))) (mkdir-p (string-append out "/etc/ssl/certs")) (call-with-output-file (string-append out "/etc/ssl/certs/ca-certificates.crt") (const #t)))))))) (p2 (package (inherit p1) (name "bar"))) (p3 (dummy-package "git" ;; Provide a fake Git to avoid building the real one. (build-system trivial-build-system) (arguments `(#:guile ,%bootstrap-guile #:builder (begin (mkdir (assoc-ref %outputs "out")) #t))) (native-search-paths (package-native-search-paths git)))) (prof1 (run-with-store %store (profile-derivation (packages->manifest (list p1 p3)) #:hooks '() #:locales? #f) #:guile-for-build (%guile-for-build))) (prof2 (run-with-store %store (profile-derivation (packages->manifest (list p2 p3)) #:hooks '() #:locales? #f) #:guile-for-build (%guile-for-build)))) (build-derivations %store (list prof1 prof2)) (string-match (format #f "^export GIT_SSL_CAINFO=\"~a/etc/ssl/certs/ca-certificates.crt" (regexp-quote (derivation->output-path prof1))) (with-output-to-string (lambda () (guix-package "-p" (derivation->output-path prof1) "-p" (derivation->output-path prof2) "--search-paths")))))) (test-equal "specification->package when not found" 'quit (catch 'quit (lambda () ;; This should call 'leave', producing an error message. (specification->package "this-package-does-not-exist")) (lambda (key . args) key))) (test-equal "specification->package+output" `((,coreutils "out") (,coreutils "debug")) (list (call-with-values (lambda () (specification->package+output "coreutils")) list) (call-with-values (lambda () (specification->package+output "coreutils:debug")) list))) (test-equal "specification->package+output invalid output" 'error (catch 'quit (lambda () (specification->package+output "coreutils:does-not-exist")) (lambda _ 'error))) (test-equal "specification->package+output no default output" `(,coreutils #f) (call-with-values (lambda () (specification->package+output "coreutils" #f)) list)) (test-equal "specification->package+output invalid output, no default" 'error (catch 'quit (lambda () (specification->package+output "coreutils:does-not-exist" #f)) (lambda _ 'error))) (test-equal "find-package-locations" (map (lambda (package) (cons (package-version package) (package-location package))) (find-packages-by-name "guile")) (find-package-locations "guile")) (test-equal "find-package-locations with cache" (map (lambda (package) (cons (package-version package) (package-location package))) (find-packages-by-name "guile")) (call-with-temporary-directory (lambda (cache) (generate-package-cache cache) (mock ((guix describe) current-profile (const cache)) (mock ((gnu packages) cache-is-authoritative? (const #t)) (find-package-locations "guile")))))) (test-equal "specification->location" (package-location (specification->package "guile@2")) (specification->location "guile@2")) (test-equal "package-unique-version-prefix, gcc@8" "8" (let ((gcc (specification->package "gcc-toolchain@8"))) (package-unique-version-prefix (package-name gcc) (package-version gcc)))) (test-equal "package-unique-version-prefix, grep" "" (let ((grep (specification->package "grep"))) (package-unique-version-prefix (package-name grep) (package-version grep)))) (test-eq "this-package-input, exists" hello (package-arguments (dummy-package "a" (inputs `(("hello" ,hello))) (arguments (this-package-input "hello"))))) (test-eq "this-package-input, exists in propagated-inputs" hello (package-arguments (dummy-package "a" (propagated-inputs `(("hello" ,hello))) (arguments (this-package-input "hello"))))) (test-eq "this-package-input, does not exist" #f (package-arguments (dummy-package "a" (arguments (this-package-input "hello"))))) (test-eq "this-package-native-input, exists" hello (package-arguments (dummy-package "a" (native-inputs `(("hello" ,hello))) (arguments (this-package-native-input "hello"))))) (test-eq "this-package-native-input, does not exists" #f (package-arguments (dummy-package "a" (arguments (this-package-native-input "hello"))))) (test-equal "this-package-input, origin" "http://example.org/foo.tar.gz" (origin-uri (package-arguments (dummy-package "a" (inputs (list (dummy-origin (uri "http://example.org/foo.tar.gz")))) (arguments (this-package-input "foo.tar.gz")))))) (test-eq "modify-inputs, replace" coreutils ;; Replace an input; notice that the label in unchanged. (let* ((p1 (dummy-package "p" (inputs (list hello)))) (p2 (package (inherit p1) (version "1") (inputs (modify-inputs (package-inputs p1) (replace "hello" coreutils)))))) (lookup-package-input p2 "hello"))) (test-eq "modify-inputs, replace, change output" guile-3.0 ;; Replace an input and choose a different output. (let* ((p1 (dummy-package "p" (inputs (list `(,coreutils "debug"))))) (p2 (package (inherit p1) (version "1") (inputs (modify-inputs (package-inputs p1) (replace "coreutils" `(,guile-3.0 "out"))))))) (match (package-inputs p2) ((("coreutils" input "out")) input)))) (test-eq "modify-inputs, replace, extra output" guile-3.0 ;; Replace an input; notice that its output is preserved. ;; See <https://issues.guix.gnu.org/53915>. (let* ((p1 (dummy-package "p" (inputs (list `(,coreutils "debug"))))) (p2 (package (inherit p1) (version "1") (inputs (modify-inputs (package-inputs p1) (replace "coreutils" guile-3.0)))))) (match (package-inputs p2) ((("coreutils" input "debug")) input)))) (test-end "packages") ;;; Local Variables: ;;; eval: (put 'dummy-package 'scheme-indent-function 1) ;;; eval: (put 'dummy-package/no-implicit 'scheme-indent-function 1) ;;; End: