How to get Elixir to use OTP-25 in NixOs


I’m trying NixOS these days, and while I love the principle, I think it leads to duplication of installed packaged and dependencies:

With this configuration:

{ pkgs, ... }:

  nixpkgs.overlays = [
    (self: super: {
      erlang = (super.erlang.override {
        version = "25.3";
        sha256 = "UOBrDaXpvpeM79VN0PxVQ1XsYI+OYWBbaBfYE5lZXgE=";

  environment.systemPackages = with pkgs; [
    # ...


I get the following in my shell:

[lud@nixos:~]$ erl
Erlang/OTP 25 [erts-13.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

[lud@nixos:~]$ elixir --version
Erlang/OTP 24 [erts-] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit]

Elixir 1.14.2 (compiled with Erlang/OTP 24)

I can hack the same kind of override for elixir, but nix only let me override the argumens for the function defined here

But the erlang package is defined in the higher scope.

I thought I had found the asdf killer but know I doubt :smiley:

Edit: pinging @NobbZ 'cause I found a lot of your posts on google :slight_smile:

I use this in my shell

{ pkgs ? (import <nixpkgs> {}), ... }:
with pkgs;
  otp = beam.packages.erlangR25;
  basePackages = [
  # Hot reloading stuff
  inputs = basePackages ++ lib.optionals stdenv.isLinux [ inotify-tools ]
    ++ lib.optionals stdenv.isDarwin
    (with darwin.apple_sdk.frameworks; [ CoreFoundation CoreServices ]);
in pkgs.mkShell {
  buildInputs = inputs;

  # keep your shell history in iex
  ERL_AFLAGS = "-kernel shell_history enabled";

  shellHook = ''
    # this isolates mix to work only in local directory
    mkdir -p .nix-mix .nix-hex
    export MIX_HOME=$PWD/.nix-mix
    export HEX_HOME=$PWD/.nix-hex

    # make hex from Nixpkgs available
    # `mix local.hex` will install hex into MIX_HOME and should take precedence
    export MIX_PATH="${otp.hex}/lib/erlang/lib/hex/ebin"
    export PATH=$MIX_HOME/bin:$HEX_HOME/bin:$PATH
1 Like

Alright so the following seems to work in the nix config:


Now how did you know there was a beam package?

On the website, the beam seems to be a haskell thing : NixOS Search (2nd- result)

1 Like

Well I wonder why I never went into that with that many google searches but thanks :smiley:

1 Like

Don’t forget to mark the solution, please

Yep, Thank you.

Unrelated, but you might like guix. It’s the same principles as nix, but comprehensible.

1 Like

That is interesting but it seems to be more restrictive about non-free packages for instance.

I am not ready to abandon vscode sadly :slight_smile:

1 Like

No need. There are two options:

  1. Just add guix as a package manager and it will install the binaries as a “foreign” system.
  2. If you want to install guix as a full-blown OS, then you can add the nonguix repositories and get non-free stuff working. No one advertises it, but it works. Also, some packages I’ve installed via flatpak (like firefox).

I started off with nix myself, but everytime I had to update, I had this complete dread that I would destroy the system. No such feeling with guix.

1 Like

While I like Scheme, I personally find Guix derivations harder to read than Nix. Also almost hostility towards non-free packages (in FSF sense) and host systems make Guix no-go zone for me.

For me FSF approach towards the software is on the “absurd” side of the spectrum, just like Oracle or Nintendo is on the exact opposite of spectrum in the “absurd” region.

Idea is glorious, but execution - not much. I am happy user of Nix on Darwin and while I always wanted to try Guix, their community and approach to people with other requirements/goals is something that keeps me out of it. Fortunately Nix is learning their lesson and they are fixing CLI into more useable and manageable form.


Yeah I looked quickly into Guix but i stopped at “flatpak”. First it defeats the purpose of having a reproducible OS configuration, and secondly in particular flatpak has not been nice with me :smiley: Though it is interesting.

I suck at sysadmin, but my needs are quite simple.

1 Like

How interesting. I don’t know if I’ve run into those members of the community. Obviously, the stance is that of the FSF, which is inherently impractical, however, it does serve a function as a signpost. Other than Stallman, those I have interacted with are fairly practical. I haven’t had to use nonguix yet, but apparently it is really good on the gaming side.

I use it for firefox because guix has icecat of a dubious version. It does have chromium though. I believe that you can also pull from nix packages, but I haven’t done it myself.

I really wanted to like Nix, but I struggled for an untold number of hours. I do think guix is much easier, but perhaps that’s because I just use a browser and emacs…