How do I use a flake to get an Elixir dev environment with specific Elixir and Erlang versions?

Hello everyone,
before I switched to NixOS I used asdf-vm to manage my Elixir and Erlang versions. After switching I learned that asdf-vm doesn’t really work on NixOS, but that flakes could practically do what I’m used to.

In my Elixir projects I need to fullfil three requirements:

  1. I need a specific Elixir version (1.15.4)
  2. I need a specific Erlang version (26.0.2)
  3. Elixir needs to be compiled with this Erlang version.

After some googling I found a flake setup that includes Elixir and Erlang, but there’s no mention about specific versions. How would I go about doing this?

Thanks :slight_smile:

In I use OTP 26 with Elixir 1.15.

The patch version are probably not as exact as you want it, Though using OTP major with Elixir minor is usally enough of pinning.

And with nix and a pinned nixpkgs input you can have much better guarantees about the environment than with asdf.

If you really want to have exact versions, you can probably use usual overrides to set the src and version attributes accordingly, though I have not played with that, as I do not consider it worth the hazzle.

There is also GitHub - shanesveller/nix-beam-flakes: Nix-based BEAM toolchain management, which can provide you much asdf style pinning. I have no experience in using it though.

1 Like

I’m gonna take a look at this, thanks a lot!