elixir-ls: build LS using the same Elixir version that is used to run LS

The Elixir LS package in Nixpkgs by default used the latest Elixir
version available to compile and run Elixir LS. The user can build
a custom Elixir LS package with a different Elixir version:

    my-custom-elixir-ls = pkgs.elixir-ls.override {
      elixir = my-custom-elixir;
    };

But by doing so the user changes only the Elixir version used to
run Elixir LS; the Elixir version used to compile Elixir LS doesn't
change. As the result, the custom Elixir LS package uses a different
Elixir version at runtime than the Elixir version it was compiled with.

In order to be able to modify the Elixir version used at build time,
I changed `mixRelease` and `fetchMixDeps` to accept `elixir` and
`hex` as parameters (defaults to the latest Elixir and Hex packages).
This commit is contained in:
Sergei Maximov 2021-11-02 15:57:13 +03:00 committed by Raphael Megzari
parent 45891c5f1c
commit 2a9336b426
3 changed files with 8 additions and 3 deletions

View File

@ -5,6 +5,7 @@
mixRelease rec {
pname = "elixir-ls";
version = "0.8.1";
inherit elixir;
src = fetchFromGitHub {
owner = "elixir-lsp";
@ -16,7 +17,7 @@ mixRelease rec {
mixFodDeps = fetchMixDeps {
pname = "mix-deps-${pname}";
inherit src version;
inherit src version elixir;
sha256 = "sha256-OzjToAg+q/ybCyqzNFk28OBsItjFTbdPi416EPh2qX0=";
};

View File

@ -1,4 +1,4 @@
{ stdenvNoCC, lib, elixir, hex, rebar, rebar3, cacert, git }:
{ stdenvNoCC, lib, elixir, hex, rebar, rebar3, cacert, git }@inputs:
{ pname
, version
@ -8,6 +8,8 @@
, debug ? false
, meta ? { }
, patches ? []
, elixir ? inputs.elixir
, hex ? inputs.hex.override { inherit elixir; }
, ...
}@attrs:

View File

@ -1,4 +1,4 @@
{ stdenv, lib, elixir, erlang, findutils, hex, rebar, rebar3, fetchMixDeps, makeWrapper, git, ripgrep }:
{ stdenv, lib, elixir, erlang, findutils, hex, rebar, rebar3, fetchMixDeps, makeWrapper, git, ripgrep }@inputs:
{ pname
, version
@ -15,6 +15,8 @@
# each dependency needs to have a setup hook to add the lib path to $ERL_LIBS
# this is how mix will find dependencies
, mixNixDeps ? { }
, elixir ? inputs.elixir
, hex ? inputs.hex.override { inherit elixir; }
, ...
}@attrs:
let