I’ve been a bit frustrated at how difficult it is to specify dependencies and their versions with dune/opam. I’m prototyping something that will force you to explicitly specify all your direct dependencies (opam or pins) and their versions. It looks something like this (in toml):
[package]
name = "my_lib"
version = "0.1.0"
[ocaml]
ocaml_version = "4.12.0"
# your dependencies go here
[dependencies]
core = "v0.14.1"
Now I’m running into this problem: how to figure out if there’s a dependency DAG that will work and install it? The only method I can think about is to manually create an opam.export file that specifies dependencies and pins and try to import it in a local switch.
I’m curious as to what your TOML format introduces over what’s already supported in .opam files. For instance, the example you gave could be written as:
With this format, opam install --with-test --with-doc . should be sufficient to install the dependencies. (This is the format that opam monorepo uses for its lock files, for instance.)
If your concern with opam files is just the syntax / ergonomics being offered, it still seems best to consider what Opam file you’d like your metadata to be “compiled down” into (since opam files already capture the kinds of queries that can be issued to the opam CLI manually).
I don’t want to sound like a gatekeeper, but I’m also surprised why anyone would have a problem with specifying dependencies in OPAM. I had experience with multiple packaging tools, and OPAM is no worse than any of them.
If your concern with opam files is just the syntax / orgonomics
But I think if the main thing you want to solve is to ‘force you to explicitly specify all your direct dependencies (opam or pins) and their versions’, then you have no choice but to use esy or nix. I mean, unless you want to reimplement package management.
The problem with that is that you specify this in dune-project files. Maybe it’s not a problem, but I’m always a bit confused as to how one should arrange a large project that contain many internal libraries with dune and dune-project files. Maybe if I create one dune-project file per library then that’s fine?
As for drom, it creates way too much configuration and boilerplate. I was looking for a cargo-like solution that favors convention over configuration (and hence only uses a few toml files and “guesses” what the different modules are based on file structure).
I’ll look at esy, but does it work with opam repository?