Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

erlang: refactor to generalize Erlang/OTP derivations #26381

Merged
merged 4 commits into from
Jun 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions pkgs/development/beam-modules/lib.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{ pkgs }:

rec {

/* Similar to callPackageWith/callPackage, but without makeOverridable
*/
callPackageWith = autoArgs: fn: args:
let
f = if builtins.isFunction fn then fn else import fn;
auto = builtins.intersectAttrs (builtins.functionArgs f) autoArgs;
in f (auto // args);

callPackage = callPackageWith pkgs;

/* Uses generic-builder to evaluate provided drv containing OTP-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, used to
enable/disable high-level OTP features, like ODBC or WX support;

Please note that "mkDerivation" defined here is the one called from R16.nix
and similar files.
*/
callErlang = drv: args:
let
builder = callPackage ../../development/interpreters/erlang/generic-builder.nix args;
in
callPackage drv {
mkDerivation = pkgs.makeOverridable builder;
};

}
58 changes: 5 additions & 53 deletions pkgs/development/interpreters/erlang/R16.nix
Original file line number Diff line number Diff line change
@@ -1,83 +1,35 @@
{ stdenv, fetchurl, perl, gnum4, ncurses, openssl
, gnused, gawk, makeWrapper
, odbcSupport ? false, unixODBC ? null
, wxSupport ? false, mesa ? null, wxGTK ? null, xorg ? null
, enableDebugInfo ? false
, Carbon ? null, Cocoa ? null }:
{ mkDerivation, fetchurl }:

assert wxSupport -> mesa != null && wxGTK != null && xorg != null;
assert odbcSupport -> unixODBC != null;

with stdenv.lib;

stdenv.mkDerivation rec {
name = "erlang-" + version + "${optionalString odbcSupport "-odbc"}";
mkDerivation rec {
version = "16B03-1";

src = fetchurl {
url = "http://www.erlang.org/download/otp_src_R${version}.tar.gz";
sha256 = "1rvyfh22g1fir1i4xn7v2md868wcmhajwhfsq97v7kn5kd2m7khp";
};

debugInfo = enableDebugInfo;

buildInputs =
[ perl gnum4 ncurses openssl makeWrapper
] ++ optionals wxSupport [ mesa wxGTK xorg.libX11 ]
++ optional odbcSupport unixODBC
++ optionals stdenv.isDarwin [ Carbon Cocoa ];

# Clang 4 (rightfully) thinks signed comparisons of pointers with NULL are nonsense
prePatch = ''
substituteInPlace lib/wx/c_src/wxe_impl.cpp --replace 'temp > NULL' 'temp != NULL'
sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure
'';

patchPhase = '' sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure '';

preConfigure = ''
export HOME=$PWD/../
sed -e s@/bin/pwd@pwd@g -i otp_build
'';

configureFlags= "--with-ssl=${openssl.dev} ${optionalString odbcSupport "--with-odbc=${unixODBC}"} ${optionalString stdenv.isDarwin "--enable-darwin-64bit"}";

# Do not install docs, instead use prebuilt versions.
installTargets = "install";
postInstall = let
manpages = fetchurl {
url = "http://www.erlang.org/download/otp_doc_man_R${version}.tar.gz";
sha256 = "17f3k5j17rdsah18gywjngip6cbfgp6nb9di6il4pahmf9yvqc8g";
};
in ''
ln -s $out/lib/erlang/lib/erl_interface*/bin/erl_call $out/bin/erl_call
tar xf "${manpages}" -C "$out/lib/erlang"
for i in "$out"/lib/erlang/man/man[0-9]/*.[0-9]; do
prefix="''${i%/*}"
ensureDir "$out/share/man/''${prefix##*/}"
ln -s "$i" "$out/share/man/''${prefix##*/}/''${i##*/}erl"
done
'';

# Some erlang bin/ scripts run sed and awk
postFixup = ''
wrapProgram $out/lib/erlang/bin/erl --prefix PATH ":" "${gnused}/bin/"
wrapProgram $out/lib/erlang/bin/start_erl --prefix PATH ":" "${stdenv.lib.makeBinPath [ gnused gawk ]}"
'';

setupHook = ./setup-hook.sh;

meta = {
homepage = "http://www.erlang.org/";
description = "Programming language used for massively scalable soft real-time systems";

longDescription = ''
Erlang is a programming language used to build massively scalable
soft real-time systems with requirements on high availability.
Some of its uses are in telecoms, banking, e-commerce, computer
telephony and instant messaging. Erlang's runtime system has
built-in support for concurrency, distribution and fault
tolerance.
'';

platforms = platforms.unix;
maintainers = [ maintainers.the-kenny ];
};
}
70 changes: 14 additions & 56 deletions pkgs/development/interpreters/erlang/R16B02-8-basho.nix
Original file line number Diff line number Diff line change
@@ -1,72 +1,38 @@
{ stdenv, fetchurl, fetchFromGitHub, perl, gnum4, ncurses, openssl, autoconf264, gcc, erlang
, gnused, gawk, makeWrapper
, odbcSupport ? false, unixODBC ? null
, wxSupport ? false, mesa ? null, wxGTK ? null, xorg ? null
, enableDebugInfo ? false
, Carbon ? null, Cocoa ? null }:
{ pkgs, mkDerivation }:

assert wxSupport -> mesa != null && wxGTK != null && xorg != null;
assert odbcSupport -> unixODBC != null;

with stdenv.lib;

stdenv.mkDerivation rec {
name = "erlang-basho-" + version + "${optionalString odbcSupport "-odbc"}";
mkDerivation rec {
baseName = "erlang";
version = "16B02";

src = fetchFromGitHub {
src = pkgs.fetchFromGitHub {
owner = "basho";
repo = "otp";
rev = "OTP_R16B02_basho8";
sha256 = "1w0hbm0axxxa45v3kl6bywc9ayir5vwqxjpnjlzc616ldszb2m0x";
};

debugInfo = enableDebugInfo;

buildInputs =
[ perl gnum4 ncurses openssl makeWrapper autoconf264 gcc
] ++ optional wxSupport [ mesa wxGTK xorg.libX11 ]
++ optional odbcSupport [ unixODBC ]
++ optionals stdenv.isDarwin [ Carbon Cocoa ];

# Clang 4 (rightfully) thinks signed comparisons of pointers with NULL are nonsense
prePatch = ''
substituteInPlace lib/wx/c_src/wxe_impl.cpp --replace 'temp > NULL' 'temp != NULL'
'';

patchPhase = '' sed -i "s@/bin/rm@rm@" lib/odbc/configure.in erts/configure.in '';

preConfigure = ''
export HOME=$PWD/../
export LANG=C
export ERL_TOP=$(pwd)
sed -e s@/bin/pwd@pwd@g -i otp_build
sed -e s@"/usr/bin/env escript"@${erlang}/bin/escript@g -i lib/diameter/bin/diameterc
'';

configureFlags= [
"--with-ssl=${openssl.dev}"
"--enable-smp-support"
"--enable-threads"
"--enable-kernel-poll"
"--disable-hipe"
"${optionalString odbcSupport "--with-odbc=${unixODBC}"}"
"${optionalString stdenv.isDarwin "--enable-darwin-64bit"}"
"${optionalString stdenv.isLinux "--enable-m64-build"}"
];
sed -e s@"/usr/bin/env escript"@$(pwd)/bootstrap/bin/escript@g -i lib/diameter/bin/diameterc

buildPhase = ''
./otp_build autoconf
./otp_build setup -a --prefix=$out $configureFlags
'';

enableHipe = false;

# Do not install docs, instead use prebuilt versions.
installTargets = "install";
postInstall = let
manpages = fetchurl {
manpages = pkgs.fetchurl {
url = "http://www.erlang.org/download/otp_doc_man_R${version}.tar.gz";
sha256 = "12apxjmmd591y9g9bhr97z5jbd1jarqg7wj0y2sqhl21hc1yp75p";
};
in ''
ln -s $out/lib/erlang/lib/erl_interface*/bin/erl_call $out/bin/erl_call
sed -e s@$(pwd)/bootstrap/bin/escript@$out/bin/escript@g -i $out/lib/erlang/lib/diameter-1.4.3/bin/diameterc

tar xf "${manpages}" -C "$out/lib/erlang"
for i in "$out"/lib/erlang/man/man[0-9]/*.[0-9]; do
prefix="''${i%/*}"
Expand All @@ -75,14 +41,6 @@ stdenv.mkDerivation rec {
done
'';

# Some erlang bin/ scripts run sed and awk
postFixup = ''
wrapProgram $out/lib/erlang/bin/erl --prefix PATH ":" "${gnused}/bin/"
wrapProgram $out/lib/erlang/bin/start_erl --prefix PATH ":" "${gnused}/bin/:${gawk}/bin"
'';

setupHook = ./setup-hook.sh;

meta = {
homepage = "https://github.com/basho/otp/";
description = "Programming language used for massively scalable soft real-time systems, Basho fork";
Expand All @@ -99,7 +57,7 @@ stdenv.mkDerivation rec {
'';

platforms = ["x86_64-linux" "x86_64-darwin"];
license = stdenv.lib.licenses.asl20;
maintainers = with maintainers; [ mdaiter ];
license = pkgs.stdenv.lib.licenses.asl20;
maintainers = with pkgs.stdenv.lib.maintainers; [ mdaiter ];
};
}
75 changes: 5 additions & 70 deletions pkgs/development/interpreters/erlang/R17.nix
Original file line number Diff line number Diff line change
@@ -1,100 +1,35 @@
{ stdenv, fetchurl, perl, gnum4, ncurses, openssl
, gnused, gawk, makeWrapper
, Carbon, Cocoa
, odbcSupport ? false, unixODBC ? null
, wxSupport ? true, mesa ? null, wxGTK ? null, xorg ? null, wxmac ? null
, javacSupport ? false, openjdk ? null
, enableHipe ? true
, enableDebugInfo ? false
, enableDirtySchedulers ? false
}:
{ mkDerivation, fetchurl }:

assert wxSupport -> (if stdenv.isDarwin
then wxmac != null
else mesa != null && wxGTK != null && xorg != null);

assert odbcSupport -> unixODBC != null;
assert javacSupport -> openjdk != null;

with stdenv.lib;

stdenv.mkDerivation rec {
name = "erlang-" + version + "${optionalString odbcSupport "-odbc"}"
+ "${optionalString javacSupport "-javac"}";
mkDerivation rec {
version = "17.5";

src = fetchurl {
url = "http://www.erlang.org/download/otp_src_${version}.tar.gz";
sha256 = "0x34hj1a4j3rphqdaapdld7la4sqiqillamcz06wac0vk0684a1w";
};

buildInputs =
[ perl gnum4 ncurses openssl makeWrapper
] ++ optionals wxSupport (if stdenv.isDarwin then [ wxmac ] else [ mesa wxGTK xorg.libX11 ])
++ optional odbcSupport unixODBC
++ optional javacSupport openjdk
++ stdenv.lib.optionals stdenv.isDarwin [ Carbon Cocoa ];

patchPhase = ''
# Clang 4 (rightfully) thinks signed comparisons of pointers with NULL are nonsense
substituteInPlace lib/wx/c_src/wxe_impl.cpp --replace 'temp > NULL' 'temp != NULL'

prePatch = ''
sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure
'';

debugInfo = enableDebugInfo;

preConfigure = ''
export HOME=$PWD/../
sed -e s@/bin/pwd@pwd@g -i otp_build
'';

configureFlags= [
"--with-ssl=${openssl.dev}"
] ++ optional enableHipe "--enable-hipe"
++ optional enableDirtySchedulers "--enable-dirty-schedulers"
++ optional wxSupport "--enable-wx"
++ optional odbcSupport "--with-odbc=${unixODBC}"
++ optional javacSupport "--with-javac"
++ optional stdenv.isDarwin "--enable-darwin-64bit";

# Do not install docs, instead use prebuilt versions.
installTargets = "install";
postInstall = let
manpages = fetchurl {
url = "http://www.erlang.org/download/otp_doc_man_${version}.tar.gz";
sha256 = "1hspm285bl7i9a0d4r6j6lm5yk4sb5d9xzpia3simh0z06hv5cc5";
};
in ''
ln -s $out/lib/erlang/lib/erl_interface*/bin/erl_call $out/bin/erl_call
tar xf "${manpages}" -C "$out/lib/erlang"
for i in "$out"/lib/erlang/man/man[0-9]/*.[0-9]; do
prefix="''${i%/*}"
ensureDir "$out/share/man/''${prefix##*/}"
ln -s "$i" "$out/share/man/''${prefix##*/}/''${i##*/}erl"
done
'';

# Some erlang bin/ scripts run sed and awk
postFixup = ''
wrapProgram $out/lib/erlang/bin/erl --prefix PATH ":" "${gnused}/bin/"
wrapProgram $out/lib/erlang/bin/start_erl --prefix PATH ":" "${stdenv.lib.makeBinPath [ gnused gawk ]}"
'';

setupHook = ./setup-hook.sh;

meta = {
homepage = "http://www.erlang.org/";
description = "Programming language used for massively scalable soft real-time systems";

longDescription = ''
Erlang is a programming language used to build massively scalable
soft real-time systems with requirements on high availability.
Some of its uses are in telecoms, banking, e-commerce, computer
telephony and instant messaging. Erlang's runtime system has
built-in support for concurrency, distribution and fault
tolerance.
'';

platforms = platforms.unix;
maintainers = [ maintainers.the-kenny maintainers.sjmackenzie ];
};
}