# Package version: source vs. binary

**URL:** <https://discuss.ocaml.org/t/package-version-source-vs-binary/3852>\
**Category:** Ecosystem\
**Created:** [May 26, 2019, 8:33am UTC](https://discuss.ocaml.org/t/package-version-source-vs-binary/3852 "2019-05-26T08:33:21Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![avsm](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/avsm/32/6_2.png) [@avsm](https://discuss.ocaml.org/u/avsm)\
**Post date:** [June 4, 2019, 3:55pm UTC](https://discuss.ocaml.org/t/package-version-source-vs-binary/3852/16 "2019-06-04T15:55:44Z")

</div>

Thanks very much for looking into this @ivg and @bobot! Just one clarification: rather than wrapping existing packages in nix (which is complex and adds multiple layers of indirection), I was thinking about this scheme:

- build a [duniverse](https://github.com/avsm/duniverse) of the set of opam packages you want to publish in nix.
- Check that it all builds using `dune build` from the toplevel directory.
- Now we add a build target to dune that will _generate_ `<name>.nix` packages based on the fine-grained build information available to dune. These should not require opam to install at all, since nix replaces opam here as the coordination mechanism for ensuring that they are compiled and installed into the system.

Dune 1.10 has support for package metadata in `dune-project`, so the only missing metadata that nix would need here is the depext information, which I would also like to add into `dune` to aid configurator probing.

> [@ivg](#):
>
> Concerning the docker support, we have a NixOS [builder](https://hub.docker.com/r/nixos/nix/), which we can use as a source of inspiration for the ocaml-dockerfile support. Besides, @avsm what do you think we need to add to ocaml-dockerfile to enable support for Nix packages?

We primarily just need the runes to know how to drive Nix in order to generate the Dockerfiles:

- [https://github.com/avsm/ocaml-dockerfile/blob/master/src-opam/dockerfile\_linux.mli](https://github.com/avsm/ocaml-dockerfile/blob/master/src-opam/dockerfile_linux.mli) for the Linux setup for apt/rpm/apk
- [https://github.com/avsm/ocaml-dockerfile/blob/master/src-opam/dockerfile\_distro.mli](https://github.com/avsm/ocaml-dockerfile/blob/master/src-opam/dockerfile_distro.mli) has all the distro information (how is nix versioned?)
- [ocaml-dockerfile/src-opam/dockerfile\_opam.ml at master · ocurrent/ocaml-dockerfile · GitHub](https://github.com/avsm/ocaml-dockerfile/blob/master/src-opam/dockerfile_opam.ml) has the logic to hook this together to generate an opam container, from which we then build all the ocaml containers.

I know nothing about Nix, so even an issue on there with instructions would be a good start towards getting Nix/OCaml containers being built regularly. It definitely seems like the next best target we should aim for in our CI.

---

_[View the full topic](https://discuss.ocaml.org/t/package-version-source-vs-binary/3852)._
