Debian Codegraph @

default.nix

raw symbols SCIP
1 # How to use?
2
3 # If you have Nix installed, you can get in an environment with everything
4 # needed to compile Rocq and RocqIDE by running:
5 # $ nix-shell
6 # at the root of the Rocq repository.
7
8 # How to tweak default arguments?
9
10 # nix-shell supports the --arg option (see Nix doc) that allows you for
11 # instance to do this:
12 # $ nix-shell --arg ocamlPackages "(import <nixpkgs> {}).ocaml-ng.ocamlPackages_4_14" --arg buildIde false
13
14 # You can also compile Rocq and "install" it by running:
15 # $ make clean # (only needed if you have left-over compilation files)
16 # $ nix-build
17 # at the root of the Rocq repository.
18 # nix-build also supports the --arg option, so you will be able to do:
19 # $ nix-build --arg doInstallCheck false
20 # if you want to speed up things by not running the test-suite.
21 # Once the build is finished, you will find, in the current directory,
22 # a symlink to where Rocq was installed.
23
24 { pkgs ? import ./dev/nixpkgs.nix {}
25 , ocamlPackages ? pkgs.ocaml-ng.ocamlPackages_4_14
26 , buildIde ? true
27 , buildDoc ? true
28 , doInstallCheck ? true
29 , shell ? false
30 # We don't use lib.inNixShell because that would also apply
31 # when in a nix-shell of some package depending on this one.
32 , coq-version ? "8.14-git"
33 }:
34
35 with pkgs;
36 with pkgs.lib;
37
38 stdenv.mkDerivation rec {
39
40 name = "coq";
41
42 buildInputs = [
43 hostname
44 python311
45 ocamlPackages.yojson
46 ocamlPackages.camlzip
47 # coq-makefile timing tools
48 time
49 dune_3
50 ]
51 ++ optionals buildIde [
52 ocamlPackages.lablgtk3-sourceview3
53 glib
54 gnome.adwaita-icon-theme
55 wrapGAppsHook
56 ]
57 ++ optionals buildDoc [
58 # Sphinx doc dependencies
59 pkg-config (python311.withPackages
60 (ps: [ ps.sphinx ps.sphinx_rtd_theme ps.pexpect ps.beautifulsoup4
61 (ps.antlr4-python3-runtime.override {antlr4 = pkgs.antlr4_9;}) ps.sphinxcontrib-bibtex ]))
62 antlr4_9
63 ocamlPackages.odoc
64 ]
65 ++ optionals doInstallCheck [
66 # Test-suite dependencies
67 ocamlPackages.ounit
68 rsync
69 which
70 ]
71 ++ optionals shell (
72 [ # Dependencies of the merging script
73 jq
74 curl
75 gitFull
76 gnupg
77 ]
78 ++ (with ocamlPackages; [
79 # Dev tools
80 ocaml-lsp
81 merlin
82 ocp-indent
83 ocp-index
84 utop
85 ocamlformat
86 ])
87 ++ [
88 # Useful for STM debugging
89 graphviz
90 ]
91 );
92
93 # OCaml and findlib are needed so that native_compute works
94 # This follows a similar change in the nixpkgs repo (cf. NixOS/nixpkgs#101058)
95 # ocamlfind looks for zarith when building plugins
96 # This follows a similar change in the nixpkgs repo (cf. NixOS/nixpkgs#94230)
97 propagatedBuildInputs = with ocamlPackages; [ ocaml findlib zarith ];
98
99 propagatedUserEnvPkgs = with ocamlPackages; [ ocaml findlib ];
100
101 src =
102 if shell then null
103 else
104 with builtins; filterSource
105 (path: _:
106 !elem (baseNameOf path) [".git" "result" "bin" "_build" "_build_ci" "_build_vo" "nix"]) ./.;
107
108 preConfigure = ''
109 patchShebangs dev/tools/ doc/corelib
110 '';
111
112 prefixKey = "-prefix ";
113
114 enableParallelBuilding = true;
115
116 buildFlags = [ "world" ] ++ optional buildIde "rocqide";
117
118 # TODO, building of documentation package when not in dev mode
119 # https://github.com/rocq-prover/rocq/issues/16198
120 # buildFlags = [ "world" ] ++ optional buildDoc "refman-html";
121
122 # From https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/ocaml/dune.nix
123 installPhase = ''
124 runHook preInstall
125 dune install --prefix $out --libdir $OCAMLFIND_DESTDIR rocq-runtime coq-core rocq-core coqide-server ${optionalString buildIde "rocqide"}
126 runHook postInstall
127 '';
128
129 # installTargets =
130 # [ "install" ];
131 # fixme, do we have to do a target, or can we just do a copy?
132 # ++ optional buildDoc "install-doc-html";
133
134 createFindlibDestdir = !shell;
135
136 postInstall = "ln -s $out/lib/rocq-runtime $OCAMLFIND_DESTDIR/rocq-runtime && ln -s $out/lib/coq-core $OCAMLFIND_DESTDIR/coq-core";
137
138 inherit doInstallCheck;
139
140 preInstallCheck = ''
141 patchShebangs tools/
142 patchShebangs test-suite/
143 export OCAMLPATH=$OCAMLFIND_DESTDIR:$OCAMLPATH
144 '';
145
146 installCheckTarget = [ "check" ];
147
148 passthru = {
149 inherit coq-version ocamlPackages;
150 dontFilter = true; # Useful to use mkCoqPackages from <nixpkgs>
151 };
152
153 setupHook = writeText "setupHook.sh" "
154 addCoqPath () {
155 if test -d \"$1/lib/coq/${coq-version}/user-contrib\"; then
156 export ROCQPATH=\"\${ROCQPATH-}\${ROCQPATH:+:}$1/lib/coq/${coq-version}/user-contrib/\"
157 fi
158 }
159
160 addEnvHooks \"$targetOffset\" addCoqPath
161 ";
162
163 meta = {
164 description = "Rocq Prover";
165 longDescription = ''
166 The Rocq Prover is an interactive theorem prover, or proof assistant. It provides a formal language
167 to write mathematical definitions, executable algorithms and theorems
168 together with an environment for semi-interactive development of
169 machine-checked proofs.
170 '';
171 homepage = https://rocq-prover.org;
172 license = licenses.lgpl21;
173 platforms = platforms.unix;
174 };
175
176 }