Opam-monorepo and os-specific dependencies

Hi there,

Does anyone have any tips for getting opam-monorepo to play nice with os-specific packages?

My project depends on eio and I develop on an M1 Mac, which means that my lockfile includes eio, eio_main, and eio_posix. This works fine until I try building a docker image, which fails due to eio_linux not being installed (technically it fails due to missing dependencies like uring, but you get the idea).

I know that I could simply opam install eio_linux in the Dockerfile, but that feels a little gross (and kinda negates the purpose of the lockfile). Is there a best practice here?

Thanks!

I should have read the docs better, sorry – it looks like lock (opam-monorepo.lock) had the info I needed.

However, opam monorepo lock --global-opam-vars '[[os-distribution,alpine],[os-family,alpine],[os,linux]]' $PACKAGE_NAME doesn’t seem to work (the lockfile still has eio_posix instead of eio_linux).

But interestingly enough, when explicitly set the global variable opam var --global os=linux, opam monorepo lock does the right thing. Maybe opam-monorepo isn’t plumbing this variable through all the way?

The best option would be to raise an issue on GH opam-monorepo, I guess you’ll get a faster feedback.

1 Like

Good call, opened an issue here: opam monorepo lock not applying global opam vars? · Issue #399 · tarides/opam-monorepo · GitHub

Tl;dr the opam var overrides only take effect if you’ve explicitly set the repository list: opam monorepo lock not applying global opam vars? · Issue #399 · tarides/opam-monorepo · GitHub