tweag / opam-nix

Turn opam-based OCaml projects into Nix derivations
MIT License
111 stars 33 forks source link

Example Request: Multi Package Project #16

Closed rgrinberg closed 2 years ago

rgrinberg commented 2 years ago

Lots of OCaml projects contain more than one opam package per project. But as far as I can tell, all the examples cover projects with only a single opam package. It would be good to include an example of this common project type as well.

balsoft commented 2 years ago

If you can come up with some good examples, I can package them and add them as examples. However, it's typically not much different from a single-package project. For an external example, see here: https://github.com/serokell/tezos-packaging/blob/master/nix/build/ocaml-overlay.nix#L12 . Although it's slightly complicated for some other reasons, the gist of it is just calling buildOpamProject' and then choosing the packages you need from the resutling scope.

rgrinberg commented 2 years ago

One good example would be https://github.com/ocaml/ocaml-lsp. A project that contains both binaries and libraries.

balsoft commented 2 years ago

Thanks!

rgrinberg commented 2 years ago

I finally took a look at the example, and I'm wondering why it uses fetchFromGithub? The other examples just assume the source is from the flake itself as one would expect

balsoft commented 2 years ago

It's to avoid adding an extra flake input to all the transitive dependencies of opam-nix.

rgrinberg commented 2 years ago

Okay. But why isn't that a problem for the other examples?

By the way, I tried the flake and it only builds the binary ocaml-lsp-server. It doesn't build any of the libraries from the jsonrpc and lsp packages.