Skip to content

Commit

Permalink
erlang: normalize version name
Browse files Browse the repository at this point in the history
  • Loading branch information
superherointj authored and Yt committed Mar 21, 2023
1 parent e400f93 commit 441cbfc
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 42 deletions.
8 changes: 4 additions & 4 deletions doc/languages-frameworks/beam.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ nixpkgs follows the [official elixir deprecation schedule](https://hexdocs.pm/el

All BEAM-related expressions are available via the top-level `beam` attribute, which includes:

- `interpreters`: a set of compilers running on the BEAM, including multiple Erlang/OTP versions (`beam.interpreters.erlangR22`, etc), Elixir (`beam.interpreters.elixir`) and LFE (Lisp Flavoured Erlang) (`beam.interpreters.lfe`).
- `interpreters`: a set of compilers running on the BEAM, including multiple Erlang/OTP versions (`beam.interpreters.erlang_22`, etc), Elixir (`beam.interpreters.elixir`) and LFE (Lisp Flavoured Erlang) (`beam.interpreters.lfe`).

- `packages`: a set of package builders (Mix and rebar3), each compiled with a specific Erlang/OTP version, e.g. `beam.packages.erlang22`.

The default Erlang compiler, defined by `beam.interpreters.erlang`, is aliased as `erlang`. The default BEAM package set is defined by `beam.packages.erlang` and aliased at the top level as `beamPackages`.

To create a package builder built with a custom Erlang version, use the lambda, `beam.packagesWith`, which accepts an Erlang/OTP derivation and produces a package builder similar to `beam.packages.erlang`.

Many Erlang/OTP distributions available in `beam.interpreters` have versions with ODBC and/or Java enabled or without wx (no observer support). For example, there's `beam.interpreters.erlangR22_odbc_javac`, which corresponds to `beam.interpreters.erlangR22` and `beam.interpreters.erlangR22_nox`, which corresponds to `beam.interpreters.erlangR22`.
Many Erlang/OTP distributions available in `beam.interpreters` have versions with ODBC and/or Java enabled or without wx (no observer support). For example, there's `beam.interpreters.erlang_22_odbc_javac`, which corresponds to `beam.interpreters.erlang_22` and `beam.interpreters.erlang_22_nox`, which corresponds to `beam.interpreters.erlang_22`.

## Build Tools {#build-tools}

Expand Down Expand Up @@ -154,7 +154,7 @@ Here is how your `default.nix` file would look for a phoenix project.
with import <nixpkgs> { };
let
# beam.interpreters.erlangR23 is available if you need a particular version
# beam.interpreters.erlang_23 is available if you need a particular version
packages = beam.packagesWith beam.interpreters.erlang;
pname = "your_project";
Expand Down Expand Up @@ -274,7 +274,7 @@ Usually, we need to create a `shell.nix` file and do our development inside of t
with pkgs;
let
elixir = beam.packages.erlangR24.elixir_1_12;
elixir = beam.packages.erlang_24.elixir_1_12;
in
mkShell {
buildInputs = [ elixir ];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pkgs/development/interpreters/erlang/generic-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ stdenv.mkDerivation ({
latest=$(list-git-tags --url=https://github.com/erlang/otp.git | sed -n 's/^OTP-${major}/${major}/p' | sort -V | tail -1)
if [ "$latest" != "${version}" ]; then
nixpkgs="$(git rev-parse --show-toplevel)"
nix_file="$nixpkgs/pkgs/development/interpreters/erlang/R${major}.nix"
nix_file="$nixpkgs/pkgs/development/interpreters/erlang/${major}.nix"
update-source-version ${baseName}R${major} "$latest" --version-key=version --print-changes --file="$nix_file"
else
echo "${baseName}R${major} is already up-to-date"
Expand Down
1 change: 1 addition & 0 deletions pkgs/top-level/aliases.nix
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ mapAliases ({
enyo-doom = enyo-launcher; # Added 2022-09-09
epoxy = libepoxy; # Added 2021-11-11
epsxe = throw "epsxe has been removed from nixpkgs, as it was unmaintained."; # added 2021-12-15
inherit (beam.interpreters) erlangR25 erlangR24 erlangR23 erlangR22 erlangR21; # added 2023-03-21
esniper = throw "esniper has been removed because upstream no longer maintains it (and it no longer works)"; # Added 2021-04-12
etcdctl = throw "'etcdctl' has been renamed to/replaced by 'etcd'"; # Converted to throw 2022-02-22
eteroj.lv2 = throw "'eteroj.lv2' has been renamed to/replaced by 'open-music-kontrollers.eteroj'"; # Added 2022-03-09
Expand Down
6 changes: 3 additions & 3 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16576,7 +16576,7 @@ with pkgs;
};

inherit (beam.interpreters)
erlang erlangR25 erlangR24 erlangR23 erlangR22 erlangR21
erlang erlang_25 erlang_24 erlang_23 erlang_22 erlang_21
erlang_odbc erlang_javac erlang_odbc_javac
elixir elixir_1_14 elixir_1_13 elixir_1_12 elixir_1_11 elixir_1_10
elixir-ls;
Expand All @@ -16588,7 +16588,7 @@ with pkgs;
rebar rebar3 rebar3WithPlugins
fetchHex beamPackages;

inherit (beam.packages.erlangR21) lfe lfe_1_3;
inherit (beam.packages.erlang_21) lfe lfe_1_3;

gnudatalanguage = callPackage ../development/interpreters/gnudatalanguage {
inherit (llvmPackages) openmp;
Expand Down Expand Up @@ -24745,7 +24745,7 @@ with pkgs;
etcd_3_4 = callPackage ../servers/etcd/3.4.nix { };
etcd_3_5 = callPackage ../servers/etcd/3.5.nix { };

ejabberd = callPackage ../servers/xmpp/ejabberd { erlang = erlangR24; };
ejabberd = callPackage ../servers/xmpp/ejabberd { erlang = erlang_24; };

exhibitor = callPackage ../servers/exhibitor { };

Expand Down
76 changes: 42 additions & 34 deletions pkgs/top-level/beam-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,25 @@

let
self = beam;

# Aliases added 2023-03-21
versionLoop = f: lib.lists.foldr (version: acc: (f version) // acc) { } [ "25" "24" "23" "22" "21" ];

interpretersAliases = versionLoop (version: {
"erlangR${version}" = self.interpreters."erlang_${version}";
"erlangR${version}_odbc" = self.interpreters."erlang_${version}_odbc";
"erlangR${version}_javac" = self.interpreters."erlang_${version}_javac";
"erlangR${version}_odbc_javac" = self.interpreters."erlang_${version}_odbc_javac";
});

packagesAliases = versionLoop (version: { "erlangR${version}" = self.packages."erlang_${version}"; });

in

{
beamLib = callPackage ../development/beam-modules/lib.nix { };

latestVersion = "erlangR25";
latestVersion = "erlang_25";

# Each
interpreters = {
Expand All @@ -29,89 +42,84 @@ in

# Standard Erlang versions, using the generic builder.

# R25
erlangR25 = self.beamLib.callErlang ../development/interpreters/erlang/R25.nix {
erlang_25 = self.beamLib.callErlang ../development/interpreters/erlang/25.nix {
wxGTK = wxGTK32;
parallelBuild = true;
autoconf = buildPackages.autoconf269;
inherit wxSupport systemdSupport;
};
erlangR25_odbc = self.interpreters.erlangR25.override { odbcSupport = true; };
erlangR25_javac = self.interpreters.erlangR25.override { javacSupport = true; };
erlangR25_odbc_javac = self.interpreters.erlangR25.override {
erlang_25_odbc = self.interpreters.erlang_25.override { odbcSupport = true; };
erlang_25_javac = self.interpreters.erlang_25.override { javacSupport = true; };
erlang_25_odbc_javac = self.interpreters.erlang_25.override {
javacSupport = true;
odbcSupport = true;
};

# R24
erlangR24 = self.beamLib.callErlang ../development/interpreters/erlang/R24.nix {
erlang_24 = self.beamLib.callErlang ../development/interpreters/erlang/24.nix {
wxGTK = wxGTK32;
# Can be enabled since the bug has been fixed in https://github.com/erlang/otp/pull/2508
parallelBuild = true;
autoconf = buildPackages.autoconf269;
inherit wxSupport systemdSupport;
};
erlangR24_odbc = self.interpreters.erlangR24.override { odbcSupport = true; };
erlangR24_javac = self.interpreters.erlangR24.override { javacSupport = true; };
erlangR24_odbc_javac = self.interpreters.erlangR24.override {
erlang_24_odbc = self.interpreters.erlang_24.override { odbcSupport = true; };
erlang_24_javac = self.interpreters.erlang_24.override { javacSupport = true; };
erlang_24_odbc_javac = self.interpreters.erlang_24.override {
javacSupport = true;
odbcSupport = true;
};

# R23
erlangR23 = self.beamLib.callErlang ../development/interpreters/erlang/R23.nix {
erlang_23 = self.beamLib.callErlang ../development/interpreters/erlang/23.nix {
openssl = openssl_1_1;
wxGTK = wxGTK32;
# Can be enabled since the bug has been fixed in https://github.com/erlang/otp/pull/2508
parallelBuild = true;
autoconf = buildPackages.autoconf269;
inherit wxSupport systemdSupport;
};
erlangR23_odbc = self.interpreters.erlangR23.override { odbcSupport = true; };
erlangR23_javac = self.interpreters.erlangR23.override { javacSupport = true; };
erlangR23_odbc_javac = self.interpreters.erlangR23.override {
erlang_23_odbc = self.interpreters.erlang_23.override { odbcSupport = true; };
erlang_23_javac = self.interpreters.erlang_23.override { javacSupport = true; };
erlang_23_odbc_javac = self.interpreters.erlang_23.override {
javacSupport = true;
odbcSupport = true;
};

# R22
erlangR22 = self.beamLib.callErlang ../development/interpreters/erlang/R22.nix {
erlang_22 = self.beamLib.callErlang ../development/interpreters/erlang/22.nix {
openssl = openssl_1_1;
wxGTK = wxGTK32;
# Can be enabled since the bug has been fixed in https://github.com/erlang/otp/pull/2508
parallelBuild = true;
autoconf = buildPackages.autoconf269;
inherit wxSupport systemdSupport;
};
erlangR22_odbc = self.interpreters.erlangR22.override { odbcSupport = true; };
erlangR22_javac = self.interpreters.erlangR22.override { javacSupport = true; };
erlangR22_odbc_javac = self.interpreters.erlangR22.override {
erlang_22_odbc = self.interpreters.erlang_22.override { odbcSupport = true; };
erlang_22_javac = self.interpreters.erlang_22.override { javacSupport = true; };
erlang_22_odbc_javac = self.interpreters.erlang_22.override {
javacSupport = true;
odbcSupport = true;
};

# R21
erlangR21 = self.beamLib.callErlang ../development/interpreters/erlang/R21.nix {
erlang_21 = self.beamLib.callErlang ../development/interpreters/erlang/21.nix {
openssl = openssl_1_1;
wxGTK = wxGTK32;
autoconf = buildPackages.autoconf269;
inherit wxSupport systemdSupport;
};
erlangR21_odbc = self.interpreters.erlangR21.override { odbcSupport = true; };
erlangR21_javac = self.interpreters.erlangR21.override { javacSupport = true; };
erlangR21_odbc_javac = self.interpreters.erlangR21.override {
erlang_21_odbc = self.interpreters.erlang_21.override { odbcSupport = true; };
erlang_21_javac = self.interpreters.erlang_21.override { javacSupport = true; };
erlang_21_odbc_javac = self.interpreters.erlang_21.override {
javacSupport = true;
odbcSupport = true;
};

# Other Beam languages. These are built with `beam.interpreters.erlang`. To
# access for example elixir built with different version of Erlang, use
# `beam.packages.erlangR24.elixir`.
# `beam.packages.erlang_24.elixir`.
inherit (self.packages.erlang)
elixir elixir_1_14 elixir_1_13 elixir_1_12 elixir_1_11 elixir_1_10 elixir-ls;

inherit (self.packages.erlang) lfe lfe_1_3;
};
} // interpretersAliases;

# Helper function to generate package set with a specific Erlang version.
packagesWith = erlang:
Expand All @@ -122,10 +130,10 @@ in
packages = {
erlang = self.packages.${self.latestVersion};

erlangR25 = self.packagesWith self.interpreters.erlangR25;
erlangR24 = self.packagesWith self.interpreters.erlangR24;
erlangR23 = self.packagesWith self.interpreters.erlangR23;
erlangR22 = self.packagesWith self.interpreters.erlangR22;
erlangR21 = self.packagesWith self.interpreters.erlangR21;
};
erlang_25 = self.packagesWith self.interpreters.erlang_25;
erlang_24 = self.packagesWith self.interpreters.erlang_24;
erlang_23 = self.packagesWith self.interpreters.erlang_23;
erlang_22 = self.packagesWith self.interpreters.erlang_22;
erlang_21 = self.packagesWith self.interpreters.erlang_21;
} // packagesAliases;
}

0 comments on commit 441cbfc

Please sign in to comment.