How can I successfully create an erlang and elixir overlay with custom version?

I need to develop on a old Elixir project that uses Elixir version 1.9 (current is 1.15). And this version of Elixir needs (for retrocompatibility with other libs) Erlang/OTP 20/22.

However, on nixpkgs there are only Elixir 1_15 to 1_10 and all are built and compiled with Erlang/OTP 25, which gives me errors on the project compilation…

I tried to make the following overlay:

erlang_overlay = _self: super: {
  erlang = super.erlang.override {
    version = "20.3.8.26";
    sha256 = "";
  };
};

elixir_overlay = _self: super: {
  elixir = (super.beam.packagesWith super.erlang).elixir.override {
    version = "1.9";
    sha256 = "";
  };
};

But this doesn’t work as expected

error: assertion '(versionAtLeast (getVersion erlang) minimumOTPVersion)' failed

       at /nix/store/5444jpr9i2hq9r1cj18528jy13idcy9p-source/pkgs/development/interpreters/elixir/generic-builder.nix:26:1:

           25| in
           26| assert versionAtLeast (getVersion erlang) minimumOTPVersion;
             | ^
           27|
(use '--show-trace' to show detailed location information)

More important than overriding the version is overriding the src.

Overriding the former is just cosmetic.

Though to be honest, get yourself a nixpkgs from 2 or 3 years ago, when the combination of elixir/OTP was current, make it compile on that and don’t touch anything in the app that isn’t required for updating elixir and OTP.

Get to 1.14/25 at the bare minimum as fast as possible.