timbertson / opam2nix

Generate nix expressions from opam packages
MIT License
93 stars 28 forks source link

More control over opam repositories in the solver phase #74

Open rgrinberg opened 3 years ago

rgrinberg commented 3 years ago

It's quite useful to be able to edit dependencies, override constraints, and in general control the solver. I'm aware that some of this is achievable using --define, but this way is not really ergonomic as one has to provide a full opam file.

Nix has a nice system for modifying things exactly where you want them with overlay and overrides. I'm wondering if it would be possible for opam2nix to have something similar? Ideally something like dumping the package universe into a nix expression, letting the user modify it and then spit it back to opam2nix to feed the solver. This seems quite complicated to implement though, so perhaps we could think of a simpler system that achieves the same thing?

timbertson commented 2 years ago

Currently the package universe is loaded directly from an opam-repository layout of opam files. So doing a roundtrip through nix seems pretty complex. What exactly would you want to override? If you're talking overrides at the field level, that seems near impossible (you'd have to translate opam syntax <-> nix syntax). If you just want to override specific packages by subbing in a new opam file, then nix's rich override support doesn't seem like it'd help you much.

rgrinberg commented 2 years ago

What exactly would you want to override?

I'd like to override constraints for specific packages to guide the solver.

If you're talking overrides at the field level, that seems near impossible (you'd have to translate opam syntax <-> nix syntax)

Is that really so hard? It seemed plausible when I first made this issue 😅