I’m working on a set of packages which all depend on a common base package. The base package is not yet in Opam because I’m still polishing it.
Until now, I’ve been vendoring that package as a git submodule in the packages which depend on it, but I’m not particularly happy with this solution.
In Python, for example, one can specify that a dependency comes from a git repository with syntax like this: some-package @ git+https://github.com/some/repository
Is there a way to do something similar with Dune?
1 Like
I figured out I can make this work for development purposes using opam pin
, but this ostensibly has to be configured per-machine.
I see that there is also a way to pin a dependency like this in an opam file, but I am not sure how this will interact with dune, which tends to rewrite the opam file.
You can use an opam template file. Dune will insert its contents into the generated final opam file. Eg ocaml-decimal/decimal.opam.template at main · yawaramin/ocaml-decimal · GitHub
2 Likes
This can also be done with dune package management. If your dependencies are in your dune-project file, then add something like this to dune-project:
(pin
(package
(name <name>)
(version <version-dune-will-see>))
(url git+https://github.com/...))
You still also need to include the dependency on the package in the (depends ...)
section of dune-project. Then run dune pkg lock
to solve dependencies and then future runs of dune build
will download and build the dependency from its git repo.
3 Likes
Thanks @yawaramin and @gridbugs. I’ll experiment with both of these approaches and see which one tickles my fancy.