Customizing installation of opam packages

Does opam have anything like, for example, Gentoo USE flags? I think homebrew has a similar concept but it’s not well documented.

Background: I want unison, but not the gtk UI for it. For now, I built it from source and it was very easy (thanks to whoever does their packaging).

It’s possible to have some optional opam dependencies and not compile part of the program when not all dependencies are installed. This convention was used more in the past but is not super easy to handle for the end users so I think that it isn’t really recommended nowadays. But still available.

I still think opam dropped the ball too early on that one.

By solving the problem of optional dependencies via package names the result is that we now have a horribly cluttered toplevel package namespace – but it did boost the package count vanity metric, which makes some people happy.

The situation is not that great. For example lots of my packages have a cli tool that uses the library it installs (e.g. uucp has ucharinfo). This tool usually uses cmdliner but I don’t want the package to formally depend on cmdliner because concretely the library does not. I also don’t want to define one more package uucp-cmdliner or uucp-ucharinfo, just for that tool, that would be ridiculous.

In any case for @nobrowser you can specify optional dependencies in the depopt: opam field, the complication are that:

  1. Constraints on a depopt package need to be specified in the conflict: field. See for
    example uucp’s opam file.
  2. There’s no ui for discovering or requesting optional configurations of your package. This means you need to instruct your users to invoke opam/specify deps with the right packages to get a desired configuration. See for example uucp’s install instructions.

Note that there was a plan to fix that, but AFAIK it’s not on the roadmap (I’d be happy to be proven wrong though).

2 Likes

I agree and it’s still planned but this is quite a large feature and i haven’t had the time to start working on it (i originally wanted to add it to 2.2 but time constraints made that this hasn’t happened, maybe for the next major release hopefully)

2 Likes