How are Ocaml packages managed in nixpkgs?

You may be interested in Developing OCaml with Nix by @ryang. The OCaml packages in Nixpkgs are definitely lagging behind and a lot are missing. This is probably due in part to the lack of maintainers able to put time into it, but also to different dependency resolution styles between opam and Nix: opam supports version constraints and uses a constraint solver, which is quite far from the Nix way of doing things and can cause complications.

The short answer is:

  • use a tool like opam-nix to generate per-project Nix shells. I know that other tools exist that fill a similar role.
  • do it imperatively using opam. This is what I do because I often work on the OCaml compiler and tools themselves and opam-nix isn’t quite designed for that use case.
  • You may want to try the Dune developer preview which is not integrated into Nix but does things in a very Nix-y way: global installation of packages (possibly in several versions) and per-project use of them.

See also Opam and nixos: is there an alternative to nix-shell?.

2 Likes