1<section xmlns="http://docbook.org/ns/docbook"
2 xmlns:xlink="http://www.w3.org/1999/xlink"
3 xml:id="sec-language-coq">
4 <title>Coq</title>
5
6 <para>
7 Coq libraries should be installed in
8 <literal>$(out)/lib/coq/${coq.coq-version}/user-contrib/</literal>. Such
9 directories are automatically added to the <literal>$COQPATH</literal>
10 environment variable by the hook defined in the Coq derivation.
11 </para>
12
13 <para>
14 Some libraries require OCaml and sometimes also Camlp5 or findlib. The exact
15 versions that were used to build Coq are saved in the
16 <literal>coq.ocaml</literal> and <literal>coq.camlp5</literal> and
17 <literal>coq.findlib</literal> attributes.
18 </para>
19
20 <para>
21 Coq libraries may be compatible with some specific versions of Coq only. The
22 <literal>compatibleCoqVersions</literal> attribute is used to precisely
23 select those versions of Coq that are compatible with this derivation.
24 </para>
25
26 <para>
27 Here is a simple package example. It is a pure Coq library, thus it depends
28 on Coq. It builds on the Mathematical Components library, thus it also takes
29 <literal>mathcomp</literal> as <literal>buildInputs</literal>. Its
30 <literal>Makefile</literal> has been generated using
31 <literal>coq_makefile</literal> so we only have to set the
32 <literal>$COQLIB</literal> variable at install time.
33 </para>
34
35<programlisting>
36{ stdenv, fetchFromGitHub, coq, mathcomp }:
37
38stdenv.mkDerivation rec {
39 name = "coq${coq.coq-version}-multinomials-${version}";
40 version = "1.0";
41 src = fetchFromGitHub {
42 owner = "math-comp";
43 repo = "multinomials";
44 rev = version;
45 sha256 = "1qmbxp1h81cy3imh627pznmng0kvv37k4hrwi2faa101s6bcx55m";
46 };
47
48 buildInputs = [ coq ];
49 propagatedBuildInputs = [ mathcomp ];
50
51 installFlags = "COQLIB=$(out)/lib/coq/${coq.coq-version}/";
52
53 meta = {
54 description = "A Coq/SSReflect Library for Monoidal Rings and Multinomials";
55 inherit (src.meta) homepage;
56 license = stdenv.lib.licenses.cecill-b;
57 inherit (coq.meta) platforms;
58 };
59
60 passthru = {
61 compatibleCoqVersions = v: builtins.elem v [ "8.5" "8.6" "8.7" ];
62 };
63}
64</programlisting>
65</section>