I work with multiple projects that require different versions of Coq. In the past I built Coq by hand, and switching version was just a matter of changing a few variables in proof-general. Now I use OPAM, but I haven’t found an easy way to switch between Coq versions.
I tried using per-project OPAM switches (in the style of Python virtualenvs), but since I also do a bit of OCaml programming along most Coq projects this requires per-project copies of Merlin, Dune, Batteries or Core, and so on. In the end each local switch takes anywhere between 500MB and 1.5GB, so having one per project isn’t ideal.
Is there a convenient way to install multiple version of Coq and switch between them with OPAM?
Bonus question, assuming that switches are the best option. In a manual build of Coq 8.8.1, coqtop is 18MB and coqc is 2.2MB. In an OPAM install of the same version, coqtop is 24MB and coqc is 3MB, and there’s an additional coqtop.byte worth 42MB. Additionally, there are two copies of most binaries, byte-compiled and native compiled. Why is Coq larger with OPAM and how can I tell OPAM to install just one copy of every binary instead of two?