What's the current best-in-class approach to packaging Elixir/Erlang/BEAM applications using Nix+releases as of July 2020?

Hey @shanesveller happy to see you around :slight_smile:

So i have been in that state for quite a long time. Right now there are no easy solutions and all the X2nix afaik depends on reading the mix.lock which is… problematic as you pointed out.

The nix ecosystem in general has two ways to handle that.

  1. Reproduce the package manager into nix itself. This is what is happening for haskell or python as an example.
  2. Do a two stage derivation, one of them fetching the whole set of dependencies using the language package manager and the lock file to ensure that you get something reproducible out of it, then validating that with a hash to satisfy the sandbox. That is how buildGoModule work as an example.

The previous solution for BEAM in nix, that i tore down last year, is to use option 1. It simply did not work out because it means regularly mirroring all of hex into nixpkgs. This need a maintenance level that is really hard to produce. As a big user of the Python ecosystem in nix, it is probably the source of most of my pain because even the Python ecosystem cannot cope.

So my current goal would be to provide a solution based on option 2. It is not particularly hard to build imho, in pure nix, it is just that i had no time to do it yet. Following the path of buildGoModule and copying their code a lot should be enough to get us going. It will need documentation and imho should be a direct PR to nixpkgs. That should be definitely doable for rebar3 too @philipstears.

This approach has problems too, it seems to have generated quite some frictions with some part of the nix community. But the other 2 options, ie depending on reading a lock file that is opaque, reverse engineering it or reproducing hex on nixpkgs, both seems like too heavy in term of maintenance to be viable.

I am ofc really open to other ideas :smiley: I would particularly like if we could get this going because it would probably solve a lot of my problems with my own CI. I have just been a bit busy lately.

I would be happy to provide review and help if someone want to get on that ship though.

2 Likes