Announce: opam2nix (v1)

Anouncing opam2nix (v1)

opam2nix generates nix expressions from the opam OCaml package repository. It works similarly to bundix, node2nix, etc:

You run an (impure) command to resolve all transitive dependency versions using the current opam repository, generating a .nix file that locks down the exact package sources and versions. Then this file can be imported to provide buildInputs for building your ocaml project in nix.

If you’ve used opam2nix v0 (which has actually been around for a few years), it worked a little differently. In v0 the entire universe of available packages was generated as .nix files, and it would resolve your dependencies purely at build time. This was convenient and allowed for some low-friction use cases, but made for quite a complex and confusing nix API, and required a frequently-updated generated packageset. The new v1 will be much more straightforward to integrate into nixpkgs itself, as updates are only required when the tool itself changes.

So if you use ocaml / opam, please give it a try and provide feedback. I’ll (slowly) start working on upstreaming it into nixpkgs.

1 Like