about summary refs log tree commit diff
path: root/pkgs/development/interpreters
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2017-06-11 20:35:07 +0200
committerGitHub <noreply@github.com>2017-06-11 20:35:07 +0200
commit4010313ab901c9022f564dfdc0e9ef27b595aa53 (patch)
tree511b37cd0266825e0b99ec24600ed78b02f8cb37 /pkgs/development/interpreters
parent370ace4cf03b31eedcf1e635ed5d52272b774526 (diff)
parentc9cb6403d3c72b01aeccc537d1cbe7954aecf29b (diff)
downloadnixlib-4010313ab901c9022f564dfdc0e9ef27b595aa53.tar
nixlib-4010313ab901c9022f564dfdc0e9ef27b595aa53.tar.gz
nixlib-4010313ab901c9022f564dfdc0e9ef27b595aa53.tar.bz2
nixlib-4010313ab901c9022f564dfdc0e9ef27b595aa53.tar.lz
nixlib-4010313ab901c9022f564dfdc0e9ef27b595aa53.tar.xz
nixlib-4010313ab901c9022f564dfdc0e9ef27b595aa53.tar.zst
nixlib-4010313ab901c9022f564dfdc0e9ef27b595aa53.zip
Merge pull request #26381 from gleber/generalize-beam
erlang: refactor to generalize Erlang/OTP derivations
Diffstat (limited to 'pkgs/development/interpreters')
-rw-r--r--pkgs/development/interpreters/erlang/R16.nix58
-rw-r--r--pkgs/development/interpreters/erlang/R16B02-8-basho.nix70
-rw-r--r--pkgs/development/interpreters/erlang/R17.nix75
-rw-r--r--pkgs/development/interpreters/erlang/R18.nix103
-rw-r--r--pkgs/development/interpreters/erlang/R19.nix99
-rw-r--r--pkgs/development/interpreters/erlang/generic-builder.nix144
6 files changed, 178 insertions, 371 deletions
diff --git a/pkgs/development/interpreters/erlang/R16.nix b/pkgs/development/interpreters/erlang/R16.nix
index e2e0151de371..123d813fc77a 100644
--- a/pkgs/development/interpreters/erlang/R16.nix
+++ b/pkgs/development/interpreters/erlang/R16.nix
@@ -1,17 +1,6 @@
-{ 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 {
@@ -19,35 +8,23 @@ stdenv.mkDerivation rec {
     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%/*}"
@@ -55,29 +32,4 @@ stdenv.mkDerivation rec {
       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 ];
-  };
 }
diff --git a/pkgs/development/interpreters/erlang/R16B02-8-basho.nix b/pkgs/development/interpreters/erlang/R16B02-8-basho.nix
index 80f524019df0..89c97f5a0eb7 100644
--- a/pkgs/development/interpreters/erlang/R16B02-8-basho.nix
+++ b/pkgs/development/interpreters/erlang/R16B02-8-basho.nix
@@ -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%/*}"
@@ -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";
@@ -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 ];
   };
 }
diff --git a/pkgs/development/interpreters/erlang/R17.nix b/pkgs/development/interpreters/erlang/R17.nix
index 0869285d4965..02d7513331eb 100644
--- a/pkgs/development/interpreters/erlang/R17.nix
+++ b/pkgs/development/interpreters/erlang/R17.nix
@@ -1,26 +1,6 @@
-{ 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 {
@@ -28,43 +8,23 @@ stdenv.mkDerivation rec {
     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%/*}"
@@ -72,29 +32,4 @@ stdenv.mkDerivation rec {
       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 ];
-  };
 }
diff --git a/pkgs/development/interpreters/erlang/R18.nix b/pkgs/development/interpreters/erlang/R18.nix
index 1ed9bfbd70a2..0d20ae662a50 100644
--- a/pkgs/development/interpreters/erlang/R18.nix
+++ b/pkgs/development/interpreters/erlang/R18.nix
@@ -1,113 +1,22 @@
-{ stdenv, fetchurl, fetchpatch, fetchFromGitHub, perl, gnum4, ncurses, openssl
-, gnused, gawk, autoconf, libxslt, libxml2, 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
-}:
-
-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"}";
-  version = "18.3.4.4";
-
-  # Minor OTP releases are not always released as tarbals at
-  # http://erlang.org/download/ So we have to download from
-  # github. And for the same reason we can't use a prebuilt manpages
-  # tarball and need to build manpages ourselves.
-  src = fetchFromGitHub {
-    owner = "erlang";
-    repo = "otp";
-    rev = "OTP-${version}";
-    sha256 = "0wilm21yi9m3v6j26vc04hsa58cxca5z4q9yxx71hm81cbm1xbwk";
-  };
-
-  buildInputs =
-    [ perl gnum4 ncurses openssl autoconf libxslt libxml2 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 ];
-
-  debugInfo = enableDebugInfo;
+{ mkDerivation, fetchurl }:
 
+let
   rmAndPwdPatch = fetchurl {
      url = "https://github.com/erlang/otp/commit/98b8650d22e94a5ff839170833f691294f6276d0.patch";
      sha256 = "0cd5pkqrigiqz6cyma5irqwzn0bi17k371k9vlg8ir31h3zmqfip";
   };
 
   envAndCpPatch = fetchurl {
-     url = "https://github.com/binarin/otp/commit/9f9841eb7327c9fe73e84e197fd2965a97b639cf.patch";
+     url = "https://github.com/erlang/otp/commit/9f9841eb7327c9fe73e84e197fd2965a97b639cf.patch";
      sha256 = "10h5348p6g279b4q01i5jdqlljww5chcvrx5b4b0dv79pk0p0m9f";
   };
 
-  # 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'
-  '';
+in mkDerivation rec {
+  version = "18.3.4.4";
+  sha256 = "0wilm21yi9m3v6j26vc04hsa58cxca5z4q9yxx71hm81cbm1xbwk";
 
   patches = [
     rmAndPwdPatch
     envAndCpPatch
   ];
-
-  preConfigure = ''
-    ./otp_build autoconf
-  '';
-
-  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";
-
-  # install-docs will generate and install manpages and html docs
-  # (PDFs are generated only when fop is available).
-  installTargets = "install install-docs";
-
-  postInstall = ''
-    ln -s $out/lib/erlang/lib/erl_interface*/bin/erl_call $out/bin/erl_call
-  '';
-
-  # 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/";
-    downloadPage = "http://www.erlang.org/download.html";
-    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 = with maintainers; [ the-kenny sjmackenzie couchemar ];
-    license = licenses.asl20;
-  };
 }
diff --git a/pkgs/development/interpreters/erlang/R19.nix b/pkgs/development/interpreters/erlang/R19.nix
index 4b1e3f4cb2f9..680111dbd77a 100644
--- a/pkgs/development/interpreters/erlang/R19.nix
+++ b/pkgs/development/interpreters/erlang/R19.nix
@@ -1,101 +1,10 @@
-{ stdenv, fetchurl, fetchFromGitHub, perl, gnum4, ncurses, openssl
-, gnused, gawk, autoconf, libxslt, libxml2, 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 = "19.3";
-
-  # Minor OTP releases are not always released as tarbals at
-  # http://erlang.org/download/ So we have to download from
-  # github. And for the same reason we can't use a prebuilt manpages
-  # tarball and need to build manpages ourselves.
-  src = fetchFromGitHub {
-    owner = "erlang";
-    repo = "otp";
-    rev = "OTP-${version}";
-    sha256 = "0pp2hl8jf4iafpnsmf0q7jbm313daqzif6ajqcmjyl87m5pssr86";
-  };
-
-  buildInputs =
-    [ perl gnum4 ncurses openssl autoconf libxslt libxml2 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 ];
-
-  debugInfo = enableDebugInfo;
+  sha256 = "0pp2hl8jf4iafpnsmf0q7jbm313daqzif6ajqcmjyl87m5pssr86";
 
   prePatch = ''
-    substituteInPlace configure.in \
-      --replace '`sw_vers -productVersion`' '10.10'
-
-    # 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'
+    substituteInPlace configure.in --replace '`sw_vers -productVersion`' '10.10'
   '';
-
-  preConfigure = ''
-    ./otp_build autoconf
-  '';
-
-  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";
-
-  # install-docs will generate and install manpages and html docs
-  # (PDFs are generated only when fop is available).
-  installTargets = "install install-docs";
-
-  postInstall = ''
-    ln -s $out/lib/erlang/lib/erl_interface*/bin/erl_call $out/bin/erl_call
-  '';
-
-  # 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/";
-    downloadPage = "http://www.erlang.org/download.html";
-    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 = with maintainers; [ yurrriq couchemar DerTim1 mdaiter ];
-    license = licenses.asl20;
-  };
 }
diff --git a/pkgs/development/interpreters/erlang/generic-builder.nix b/pkgs/development/interpreters/erlang/generic-builder.nix
new file mode 100644
index 000000000000..3434603f3028
--- /dev/null
+++ b/pkgs/development/interpreters/erlang/generic-builder.nix
@@ -0,0 +1,144 @@
+{ pkgs, stdenv, fetchurl, fetchFromGitHub, makeWrapper, gawk, gnum4, gnused
+, libxml2, libxslt, ncurses, openssl, perl, gcc, autoreconfHook
+, openjdk ? null # javacSupport
+, unixODBC ? null # odbcSupport
+, mesa ? null, wxGTK ? null, wxmac ? null, xorg ? null # wxSupport
+}:
+
+{ baseName ? "erlang"
+, version
+, sha256 ? null
+, rev ? "OTP-${version}"
+, src ? fetchFromGitHub { inherit rev sha256; owner = "erlang"; repo = "otp"; }
+, enableHipe ? true
+, enableDebugInfo ? false
+, enableThreads ? true
+, enableSmpSupport ? true
+, enableKernelPoll ? true
+, javacSupport ? false, javacPackages ? [ openjdk ]
+, odbcSupport ? false, odbcPackages ? [ unixODBC ]
+, wxSupport ? true, wxPackages ? [ mesa wxGTK xorg.libX11 ]
+, preUnpack ? "", postUnpack ? ""
+, patches ? [], patchPhase ? "", prePatch ? "", postPatch ? ""
+, configureFlags ? [], configurePhase ? "", preConfigure ? "", postConfigure ? ""
+, buildPhase ? "", preBuild ? "", postBuild ? ""
+, installPhase ? "", preInstall ? "", postInstall ? ""
+, installTargets ? "install install-docs"
+, checkPhase ? "", preCheck ? "", postCheck ? ""
+, fixupPhase ? "", preFixup ? "", postFixup ? ""
+, meta ? null
+}:
+
+assert wxSupport -> (if stdenv.isDarwin
+  then wxmac != null
+  else mesa != null && wxGTK != null && xorg != null);
+
+assert odbcSupport -> unixODBC != null;
+assert javacSupport -> openjdk != null;
+
+let
+  inherit (stdenv.lib) optional optionals optionalAttrs optionalString;
+  wxPackages2 = if stdenv.isDarwin then [ wxmac ] else wxPackages;
+
+in stdenv.mkDerivation ({
+  name = "${baseName}-${version}"
+    + optionalString javacSupport "-javac"
+    + optionalString odbcSupport "-odbc";
+
+  inherit src version;
+
+  buildInputs =
+   [ perl gnum4 ncurses openssl autoreconfHook libxslt libxml2 makeWrapper gcc
+   ]
+    ++ optionals wxSupport wxPackages2
+    ++ optionals odbcSupport odbcPackages
+    ++ optionals javacSupport javacPackages
+    ++ optionals stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [ Carbon Cocoa ]);
+
+  debugInfo = enableDebugInfo;
+
+  # 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'
+
+    ${prePatch}
+  '';
+
+  postPatch = ''
+    ${postPatch}
+
+    patchShebangs make
+  '';
+
+  preConfigure = ''
+    ./otp_build autoconf
+  '';
+
+  configureFlags = [ "--with-ssl=${openssl.dev}" ]
+    ++ optional enableThreads "--enable-threads"
+    ++ optional enableSmpSupport "--enable-smp-support"
+    ++ optional enableKernelPoll "--enable-kernel-poll"
+    ++ optional enableHipe "--enable-hipe"
+    ++ optional javacSupport "--with-javac"
+    ++ optional odbcSupport "--with-odbc=${unixODBC}"
+    ++ optional wxSupport "--enable-wx"
+    ++ optional stdenv.isDarwin "--enable-darwin-64bit";
+
+  # install-docs will generate and install manpages and html docs
+  # (PDFs are generated only when fop is available).
+
+  postInstall = ''
+    ${postInstall}
+
+    ln -s $out/lib/erlang/lib/erl_interface*/bin/erl_call $out/bin/erl_call
+  '';
+
+  # 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 = with stdenv.lib; {
+    homepage = "http://www.erlang.org/";
+    downloadPage = "http://www.erlang.org/download.html";
+    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 = with maintainers; [ the-kenny sjmackenzie couchemar gleber ];
+    license = licenses.asl20;
+  };
+}
+// optionalAttrs (preUnpack != "")      { inherit preUnpack; }
+// optionalAttrs (postUnpack != "")     { inherit postUnpack; }
+// optionalAttrs (patches != [])        { inherit patches; }
+// optionalAttrs (patchPhase != "")     { inherit patchPhase; }
+// optionalAttrs (configureFlags != []) { inherit configureFlags; }
+// optionalAttrs (configurePhase != "") { inherit configurePhase; }
+// optionalAttrs (preConfigure != "")   { inherit preConfigure; }
+// optionalAttrs (postConfigure != "")  { inherit postConfigure; }
+// optionalAttrs (buildPhase != "")     { inherit buildPhase; }
+// optionalAttrs (preBuild != "")       { inherit preBuild; }
+// optionalAttrs (postBuild != "")      { inherit postBuild; }
+// optionalAttrs (checkPhase != "")     { inherit checkPhase; }
+// optionalAttrs (preCheck != "")       { inherit preCheck; }
+// optionalAttrs (postCheck != "")      { inherit postCheck; }
+// optionalAttrs (installPhase != "")   { inherit installPhase; }
+// optionalAttrs (installTargets != "") { inherit installTargets; }
+// optionalAttrs (preInstall != "")     { inherit preInstall; }
+// optionalAttrs (fixupPhase != "")     { inherit fixupPhase; }
+// optionalAttrs (preFixup != "")       { inherit preFixup; }
+// optionalAttrs (postFixup != "")      { inherit postFixup; }
+// optionalAttrs (meta != null)         { inherit meta; }
+)