Deps_nix: mix2nix alternative as a mix task

deps_nix is a Nix derivation builder for Elixir. It’s intended as a drop-in replacement for mix2nix (which has been awesome), bringing with it support for git dependencies and environment/package selection.

Instead of being distributed via Nix, it’s a Hex package that adds a Mix task to your project. This has a few advantages, like being able to release quickly and supporting automatic changes on deps.get and deps.update via optional aliases.

I started this project after using mix2nix at work, and finding a few shortcomings:

  • Lack of git dependencies: our team needed to write custom derivations for ex_cldr and so on.
  • Redundant derivations: we currently use derivations at release-time only, and it got a bit old seeing derivation changes in diffs when non-prod dependencies were changed.
  • Formatting: a minor thing, but I wanted to nixpkgs-fmt the resulting derivations without an extra step.

I considered adding per-environment selection to mix2nix, but it would’ve been a big change to incorporate knowledge of dependency declarations as well as the lock file. Instead, deps_nix calls into Mix itself to get the dependency graph, so it is privy to more information than the lock file exposes.

Please give it a whirl and send over your advice, and let me know if your dependencies have problems!

11 Likes