From 7797e1a1dda661476dbb312b1f26896d32831ef5 Mon Sep 17 00:00:00 2001 From: Gleb Peregud Date: Sun, 18 Jun 2017 19:24:18 +0200 Subject: [PATCH] erlang: put Elixir/LFE into per-OTP packageset. This makes beam.package.erlangR19.abnf to be actually built with R19, instead of the default R18. It means that Elixir and LFE are provided in two versions, one built with R18 and with R19. Please note that Elixir does not build with R16 and R17 - trying to access beam.packages.erlang{R16,R17}.elixir will throw an error. --- pkgs/development/beam-modules/default.nix | 16 ++++++++++++---- pkgs/development/beam-modules/lib.nix | 11 ++++++++++- pkgs/top-level/beam-packages.nix | 10 ++++++---- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/pkgs/development/beam-modules/default.nix b/pkgs/development/beam-modules/default.nix index 00443350a7d..0db695befe6 100644 --- a/pkgs/development/beam-modules/default.nix +++ b/pkgs/development/beam-modules/default.nix @@ -1,7 +1,9 @@ { stdenv, pkgs, erlang, overrides ? (self: super: {}) }: let - inherit (stdenv.lib) fix' extends; + inherit (stdenv.lib) fix' extends getVersion versionAtLeast; + + lib = pkgs.callPackage ./lib.nix {}; # FIXME: add support for overrideScope callPackageWithScope = scope: drv: args: stdenv.lib.callPackageWith scope drv args; @@ -34,12 +36,18 @@ let buildErlangMk = callPackage ./build-erlang-mk.nix {}; buildMix = callPackage ./build-mix.nix {}; - ## Non hex packages + # BEAM-based languages. + elixir = if versionAtLeast (lib.getVersion erlang) "18" + then callPackage ../interpreters/elixir { debugInfo = true; } + else throw "Elixir requires at least Erlang/OTP R18."; + lfe = callPackage ../interpreters/lfe { }; + + # Non hex packages hex = callPackage ./hex {}; webdriver = callPackage ./webdriver {}; - hex2nix = callPackage ../tools/erlang/hex2nix { }; - cuter = callPackage ../tools/erlang/cuter { }; + hex2nix = callPackage ../tools/erlang/hex2nix {}; + cuter = callPackage ../tools/erlang/cuter {}; relxExe = callPackage ../tools/erlang/relx-exe {}; }; in fix' (extends overrides packages) diff --git a/pkgs/development/beam-modules/lib.nix b/pkgs/development/beam-modules/lib.nix index ae2705613f0..009bfb4975b 100644 --- a/pkgs/development/beam-modules/lib.nix +++ b/pkgs/development/beam-modules/lib.nix @@ -1,4 +1,4 @@ -{ pkgs }: +{ pkgs, stdenv }: rec { @@ -12,6 +12,15 @@ rec { callPackage = callPackageWith pkgs; + /* Erlang/OTP-specific version retrieval, returns 19 for OTP R19 */ + getVersion = x: + let + parse = drv: (builtins.parseDrvName drv).version; + in builtins.replaceStrings ["B" "-"] ["." "."] ( + if builtins.isString x + then parse x + else x.version or (parse x.name)); + /* Uses generic-builder to evaluate provided drv containing OTP-version specific data. diff --git a/pkgs/top-level/beam-packages.nix b/pkgs/top-level/beam-packages.nix index ccf22d6c534..9e0234ac1e2 100644 --- a/pkgs/top-level/beam-packages.nix +++ b/pkgs/top-level/beam-packages.nix @@ -1,7 +1,7 @@ { pkgs, stdenv, callPackage, wxGTK30, darwin }: rec { - lib = import ../development/beam-modules/lib.nix { inherit pkgs; }; + lib = callPackage ../development/beam-modules/lib.nix {}; # Each interpreters = rec { @@ -45,9 +45,11 @@ rec { odbcSupport = true; }; - # Other Beam languages. These are built with beam.interpreters.erlang. - elixir = callPackage ../development/interpreters/elixir { debugInfo = true; }; - lfe = callPackage ../development/interpreters/lfe { }; + # Other Beam languages. These are built with `beam.interpreters.erlang`. To + # access for example elixir built with different version of Erlang, use + # `beam.packages.erlangR19.elixir`. + elixir = packages.erlang.elixir; + lfe = packages.erlang.lfe; }; # Helper function to generate package set with a specific Erlang version.