I'm trying to compile metacoq, which has an ocaml plugin, using nix. I was having some troubles; it appears thatmkCoqDerivation
is not putting COQLIB
in the environment. Compilation works fine if I explicitly export it before the compilation phase. Shouldn't COQLIB
be automatically put in scope, at least when mlPlugin
is set?
This goes beyond my expertise. Deferring to @Enrico Tassi and @Cyril Cohen.
I think I failed my communication's roll, will try again (changed the title, also):
I'm trying to build a package that depends on coq sources in ${coq}/lib/coq
. The problem is that adding coq
to extraBuildInputs
doesn't put that in the path. I guess that makes some sense since coq
is a program.
A workaround is to explicitly set the COQLIB
environment variable to the library's path.
My question is, shouldn't it makes sense to add ${coq}/lib/coq
to the path sometimes? For example when making a plugin.
Or maybe is there an easy way of adding that dependency that I'm missing.
You can simply add COQLIB = "${coq}/lib/coq"
to your derivation, no need to add it upstream.
can you share your nix file?
(However, I'm not completely sure why you would need that...)
Sure, here they are: https://github.com/smalewski/dotfiles/tree/master/derivations
The metacoq
folder has a derivation for MetaCoq 8.14 and it works fine.
The one that needed COQLIB is in template-coq-rewrite
which is the artifact for the paper 'The taming of the rew: a type theory with computational assumptions'.
So it worked, right?
I think it worked fine, but wouldn't that problem (setting COQLIB) appear for almost any ml plugin for coq since it needs to have access to the internals of coq ?
Something that really puzzles me is that I had no idea that the COQLIB
environment variable could have any relation with OCaml libraries. I went to look at the documentation, and it seems to me that this environment variable is virtually undocumented. From past work https://github.com/NixOS/nixpkgs/pull/136908 based on past discussions with @Enrico Tassi and @Vincent Laporte, it even seemed to me that this was mostly an internal variable (though maybe not in all cases).
To my knowledge coqc -where
is the "standard" way of getting access to the right directory, setting it through the nix derivation does not bring extra knowledge, nor does require the compilation of more stuff than needed. That's why I would not set it in the general mkCoqDerivation
.
These are good points, I don't understand yet why COQLIB
should be set in order to get a working nix derivation for MetaCoq, but it might be some quirk of MetaCoq setup.
Last updated: Oct 13 2024 at 01:02 UTC