@@ -0,0 +1,89 @@
1+# - coqide compilation can be disabled by setting lablgtk to null;
2+# - The csdp program used for the Micromega tactic is statically referenced.
3+# However, coq can build without csdp by setting it to null.
4+# In this case some Micromega tactics will search the user's path for the csdp program and will fail if it is not found.
5+# - The patch-level version can be specified through the `pl` argument to
6+# the derivation; it defaults to the greatest.
7+
8+{ stdenv, fetchurl, writeText, pkgconfig
9+, ocaml, findlib, camlp5, ncurses
10+, lablgtk ? null, csdp ? null
11+, pl ? "1"
12+}:
13+
14+let
15+ version = "8.6rc${pl}";
16+ sha256 = {
17+ "1" = "0wral36h39q7g2sa2z8jvjc8ggqmqsjrbs0k299n0nykmmrq1pr8";
18+ }."${pl}";
19+ coq-version = "8.6";
20+ buildIde = lablgtk != null;
21+ ideFlags = if buildIde then "-lablgtkdir ${lablgtk}/lib/ocaml/*/site-lib/lablgtk2 -coqide opt" else "";
22+ csdpPatch = if csdp != null then ''
23+ substituteInPlace plugins/micromega/sos.ml --replace "; csdp" "; ${csdp}/bin/csdp"
24+ substituteInPlace plugins/micromega/coq_micromega.ml --replace "System.is_in_system_path \"csdp\"" "true"
25+ '' else "";
26+in
27+
28+stdenv.mkDerivation {
29+ name = "coq-${version}";
30+
31+ inherit coq-version;
32+ inherit ocaml camlp5;
33+
34+ src = fetchurl {
35+ url = "http://coq.inria.fr/distrib/V${version}/files/coq-${version}.tar.gz";
36+ inherit sha256;
37+ };
38+
39+ buildInputs = [ pkgconfig ocaml findlib camlp5 ncurses lablgtk ];
40+
41+ postPatch = ''
42+ UNAME=$(type -tp uname)
43+ RM=$(type -tp rm)
44+ substituteInPlace configure --replace "/bin/uname" "$UNAME"
45+ substituteInPlace tools/beautify-archive --replace "/bin/rm" "$RM"
46+ substituteInPlace configure.ml --replace '"md5 -q"' '"md5sum"'
47+ ${csdpPatch}
48+ '';
49+
50+ setupHook = writeText "setupHook.sh" ''
51+ addCoqPath () {
52+ if test -d "''$1/lib/coq/${coq-version}/user-contrib"; then
53+ export COQPATH="''${COQPATH}''${COQPATH:+:}''$1/lib/coq/${coq-version}/user-contrib/"
54+ fi
55+ }
56+
57+ envHooks=(''${envHooks[@]} addCoqPath)
58+ '';
59+
60+ preConfigure = ''
61+ configureFlagsArray=(
62+ -opt
63+ ${ideFlags}
64+ )
65+ '';
66+
67+ prefixKey = "-prefix ";
68+
69+ buildFlags = "revision coq coqide bin/votour";
70+
71+ postInstall = ''
72+ cp bin/votour $out/bin/
73+ '';
74+
75+ meta = with stdenv.lib; {
76+ description = "Coq proof assistant";
77+ longDescription = ''
78+ Coq is a formal proof management system. It provides a formal language
79+ to write mathematical definitions, executable algorithms and theorems
80+ together with an environment for semi-interactive development of
81+ machine-checked proofs.
82+ '';
83+ homepage = "http://coq.inria.fr";
84+ license = licenses.lgpl21;
85+ branch = coq-version;
86+ maintainers = with maintainers; [ roconnor thoughtpolice vbgl ];
87+ platforms = platforms.unix;
88+ };
89+}