timbertson / opam2nix

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

dream2nix #90

Closed yilinwei closed 1 year ago

yilinwei commented 1 year ago

Hi,

I'm not sure whether you are aware, but there is currently some effort underway in unifying the various *2nix platforms called dream2nix.

Do you think that the architecture of opam2nix would be able to be ported to dream2nix easily, or would it be better to start from scratch?

timbertson commented 1 year ago

Yep, I'm aware. The author and I had a bit of back & forth on my similar project, fetlock: https://github.com/timbertson/fetlock/issues/1 (fetlock is similar in spirit, but quite different in implementation choice since it is more opinionated and logic is implemented in rust instead of nix, as much as possible).

The opam2nix extract subcommand was essentially written to support fetlock, it should be possible in theory to use this from dream2nix as well. But the opam format is complex because there are parts of expressions you can't know at generation time, only build time. So I still had to write an expression parser for a subset of the opam language in fetlock. I expect you'd need to do the same in dream2nix, unless there's a clever workaround.

yilinwei commented 1 year ago

Thank you very much!

The links are really useful to start doing the research.

I had one specific question if you wouldn't mind answering; was there a reason that you didn't use opam-lock to generate the pinned versions first rather than doing the resolution in opam2nix?

timbertson commented 1 year ago

opam-lock will:

outputs modified versions of the opam file with a .locked suffix, where all the (transitive) dependencies and pinnings have been bound strictly to the currently installed version

That means it requires you to first install things, then it'll produce a locked version. opam2nix generates a solution without installing anything or even needing a valid opam install. It's also likely that opam-lock doesn't produce enough information, so you'd still need most of opam2nix's logic on top of it.