3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #26716 from ankhers/generalize-elixir

Generalize building of Elixir interpreter
This commit is contained in:
Daiderd Jordan 2017-07-09 10:50:24 +02:00 committed by GitHub
commit 5ba05aaab9
10 changed files with 149 additions and 87 deletions

View file

@ -43,6 +43,7 @@
andrewrk = "Andrew Kelley <superjoe30@gmail.com>";
andsild = "Anders Sildnes <andsild@gmail.com>";
aneeshusa = "Aneesh Agrawal <aneeshusa@gmail.com>";
ankhers = "Justin Wood <justin.k.wood@gmail.com>";
antono = "Antono Vasiljev <self@antono.info>";
apeschar = "Albert Peschar <albert@peschar.net>";
apeyroux = "Alexandre Peyroux <alex@px.io>";

View file

@ -16,7 +16,7 @@ let
in
import ./hex-packages.nix {
inherit pkgs stdenv callPackage;
} // {
} // rec {
inherit callPackage erlang;
beamPackages = self;
@ -37,9 +37,23 @@ let
buildMix = callPackage ./build-mix.nix {};
# 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.";
elixir = elixir_1_4;
elixir_1_5_rc = lib.callElixir ../interpreters/elixir/1.5.nix {
inherit rebar erlang;
debugInfo = true;
};
elixir_1_4 = lib.callElixir ../interpreters/elixir/1.4.nix {
inherit rebar erlang;
debugInfo = true;
};
elixir_1_3 = lib.callElixir ../interpreters/elixir/1.3.nix {
inherit rebar erlang;
debugInfo = true;
};
lfe = callPackage ../interpreters/lfe { };
# Non hex packages

View file

@ -12,15 +12,6 @@ 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.
@ -43,4 +34,26 @@ rec {
mkDerivation = pkgs.makeOverridable builder;
};
/* Uses generic-builder to evaluate provided drv containing Elixir version
specific data.
drv: package containing version-specific args;
builder: generic builder for all Erlang versions;
args: arguments merged into version-specific args, used mostly to customize
dependencies;
Arguments passed to the generic-builder are overridable.
Please note that "mkDerivation" defined here is the one called from 1.4.nix
and similar files.
*/
callElixir = drv: args:
let
inherit (stdenv.lib) versionAtLeast;
builder = callPackage ../interpreters/elixir/generic-builder.nix args;
in
callPackage drv {
mkDerivation = pkgs.makeOverridable builder;
};
}

View file

@ -0,0 +1,7 @@
{ mkDerivation }:
mkDerivation rec {
version = "1.3.4";
sha256 = "01qqv1ghvfadcwcr5p88w8j217cgaf094pmpqllij3l0q1yg104l";
minimumOTPVersion = "18";
}

View file

@ -0,0 +1,7 @@
{ mkDerivation }:
mkDerivation rec {
version = "1.4.5";
sha256 = "18ivcxmh5bak13k3rjy7jjzin57rgb2nffhwnqb2wl7bpi8mrarw";
minimumOTPVersion = "18";
}

View file

@ -0,0 +1,7 @@
{ mkDerivation }:
mkDerivation rec {
version = "1.5.0-rc.0";
sha256 = "1p0sawz86w9na56c42ivdacqxzldjb9s9cvl2isj3sy4nwsa0l0j";
minimumOTPVersion = "18";
}

View file

@ -1,71 +0,0 @@
{ stdenv, fetchFromGitHub, erlang, rebar, makeWrapper, coreutils, curl, bash,
debugInfo ? false }:
stdenv.mkDerivation rec {
name = "elixir-${version}";
version = "1.4.4";
src = fetchFromGitHub {
owner = "elixir-lang";
repo = "elixir";
rev = "v${version}";
sha256 = "0m51cirkv1dahw4z2jlmz58cwmpy0dya88myx4wykq0v5bh1xbq8";
};
buildInputs = [ erlang rebar makeWrapper ];
# Elixir expects that UTF-8 locale to be set (see https://github.com/elixir-lang/elixir/issues/3548).
# In other cases there is warnings during compilation.
LANG = "en_US.UTF-8";
LC_TYPE = "en_US.UTF-8";
setupHook = ./setup-hook.sh;
inherit debugInfo;
buildFlags = if debugInfo
then "ERL_COMPILER_OPTIONS=debug_info"
else "";
preBuild = ''
# The build process uses ./rebar. Link it to the nixpkgs rebar
rm -v rebar
ln -s ${rebar}/bin/rebar rebar
substituteInPlace Makefile \
--replace "/usr/local" $out
'';
postFixup = ''
# Elixir binaries are shell scripts which run erl. Add some stuff
# to PATH so the scripts can run without problems.
for f in $out/bin/*; do
b=$(basename $f)
if [ $b == "mix" ]; then continue; fi
wrapProgram $f \
--prefix PATH ":" "${stdenv.lib.makeBinPath [ erlang coreutils curl bash ]}" \
--set CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
done
substituteInPlace $out/bin/mix \
--replace "/usr/bin/env elixir" "${coreutils}/bin/env elixir"
'';
meta = with stdenv.lib; {
homepage = "http://elixir-lang.org/";
description = "A functional, meta-programming aware language built on top of the Erlang VM";
longDescription = ''
Elixir is a functional, meta-programming aware language built on
top of the Erlang VM. It is a dynamic language with flexible
syntax and macro support that leverages Erlang's abilities to
build concurrent, distributed and fault-tolerant applications
with hot code upgrades.
'';
license = licenses.epl10;
platforms = platforms.unix;
maintainers = with maintainers; [ the-kenny havvy couchemar ];
};
}

View file

@ -0,0 +1,77 @@
{ pkgs, stdenv, fetchFromGitHub, erlang, rebar, makeWrapper,
coreutils, curl, bash, debugInfo ? false }:
{ baseName ? "elixir"
, version
, minimumOTPVersion
, sha256 ? null
, rev ? "v${version}"
, src ? fetchFromGitHub { inherit rev sha256; owner = "elixir-lang"; repo = "elixir"; }
}:
let
inherit (stdenv.lib) getVersion versionAtLeast;
in
assert versionAtLeast (getVersion erlang) minimumOTPVersion;
stdenv.mkDerivation ({
name = "${baseName}-${version}";
inherit src version;
buildInputs = [ erlang rebar makeWrapper ];
LANG = "en_US.UTF-8";
LC_TYPE = "en_US.UTF-8";
setupHook = ./setup-hook.sh;
inherit debugInfo;
buildFlags = if debugInfo
then "ERL_COMPILER_OPTIONS=debug_info"
else "";
preBuild = ''
# The build process uses ./rebar. Link it to the nixpkgs rebar
rm -v rebar
ln -s ${rebar}/bin/rebar rebar
substituteInPlace Makefile \
--replace "/usr/local" $out
'';
postFixup = ''
# Elixir binaries are shell scripts which run erl. Add some stuff
# to PATH so the scripts can run without problems.
for f in $out/bin/*; do
b=$(basename $f)
if [ "$b" = mix ]; then continue; fi
wrapProgram $f \
--prefix PATH ":" "${stdenv.lib.makeBinPath [ erlang coreutils curl bash ]}" \
--set CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
done
substituteInPlace $out/bin/mix \
--replace "/usr/bin/env elixir" "${coreutils}/bin/env elixir"
'';
meta = with stdenv.lib; {
homepage = "http://elixir-lang.org/";
description = "A functional, meta-programming aware language built on top of the Erlang VM";
longDescription = ''
Elixir is a functional, meta-programming aware language built on
top of the Erlang VM. It is a dynamic language with flexible
syntax and macro support that leverages Erlang's abilities to
build concurrent, distributed and fault-tolerant applications
with hot code upgrades.
'';
license = licenses.epl10;
platforms = platforms.unix;
maintainers = with maintainers; [ the-kenny havvy couchemar ankhers ];
};
})

View file

@ -6040,8 +6040,14 @@ with pkgs;
inherit (beam.interpreters)
erlang erlang_odbc erlang_javac erlang_odbc_javac
erlangR17 erlangR18 erlangR19 erlangR20
erlang_basho_R16B02 elixir lfe;
elixir elixir_1_5_rc elixir_1_4 elixir_1_3
lfe
erlangR16 erlangR16_odbc
erlang_basho_R16B02 erlang_basho_R16B02_odbc
erlangR17 erlangR17_odbc erlangR17_javac erlangR17_odbc_javac
erlangR18 erlangR18_odbc erlangR18_javac erlangR18_odbc_javac
erlangR19 erlangR19_odbc erlangR19_javac erlangR19_odbc_javac
erlangR20 erlangR20_odbc erlangR20_javac erlangR20_odbc_javac;
inherit (beam.packages.erlang)
rebar rebar3-open rebar3

View file

@ -56,7 +56,8 @@ rec {
# 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;
inherit (packages.erlang) elixir elixir_1_5_rc elixir_1_4 elixir_1_3;
lfe = packages.erlang.lfe;
};