2021-06-04 09:07:49 +00:00
|
|
|
{ pkgs
|
|
|
|
, lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, makeWrapper
|
|
|
|
, gawk
|
|
|
|
, gnum4
|
|
|
|
, gnused
|
|
|
|
, libxml2
|
|
|
|
, libxslt
|
|
|
|
, ncurses
|
|
|
|
, openssl
|
|
|
|
, perl
|
2024-06-20 14:57:18 +00:00
|
|
|
, runtimeShell
|
2021-06-04 09:07:49 +00:00
|
|
|
, autoconf
|
2021-02-16 17:04:54 +00:00
|
|
|
, openjdk11 ? null # javacSupport
|
2020-04-24 23:36:52 +00:00
|
|
|
, unixODBC ? null # odbcSupport
|
2021-06-04 09:07:49 +00:00
|
|
|
, libGL ? null
|
|
|
|
, libGLU ? null
|
|
|
|
, wxGTK ? null
|
|
|
|
, xorg ? null
|
2024-09-19 14:19:46 +00:00
|
|
|
, ex_doc ? null
|
2020-07-18 16:06:22 +00:00
|
|
|
, parallelBuild ? false
|
2021-06-04 09:07:49 +00:00
|
|
|
, systemd
|
|
|
|
, wxSupport ? true
|
2024-09-19 14:19:46 +00:00
|
|
|
, ex_docSupport ? false
|
2023-02-02 18:25:31 +00:00
|
|
|
, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd # systemd support in epmd
|
2021-06-04 09:07:49 +00:00
|
|
|
# updateScript deps
|
|
|
|
, writeScript
|
|
|
|
, common-updater-scripts
|
|
|
|
, coreutils
|
|
|
|
, git
|
2024-05-15 15:35:15 +00:00
|
|
|
, wrapGAppsHook3
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
{ 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
|
2021-06-04 09:07:49 +00:00
|
|
|
, javacSupport ? false
|
|
|
|
, javacPackages ? [ openjdk11 ]
|
|
|
|
, odbcSupport ? false
|
|
|
|
, odbcPackages ? [ unixODBC ]
|
2021-02-17 17:02:09 +00:00
|
|
|
, opensslPackage ? openssl
|
2024-05-15 15:35:15 +00:00
|
|
|
, wxPackages ? [ libGL libGLU wxGTK xorg.libX11 wrapGAppsHook3 ]
|
2021-06-04 09:07:49 +00:00
|
|
|
, preUnpack ? ""
|
|
|
|
, postUnpack ? ""
|
|
|
|
, patches ? [ ]
|
|
|
|
, patchPhase ? ""
|
|
|
|
, prePatch ? ""
|
|
|
|
, postPatch ? ""
|
|
|
|
, configureFlags ? [ ]
|
|
|
|
, configurePhase ? ""
|
|
|
|
, preConfigure ? ""
|
|
|
|
, postConfigure ? ""
|
|
|
|
, buildPhase ? ""
|
|
|
|
, preBuild ? ""
|
|
|
|
, postBuild ? ""
|
|
|
|
, installPhase ? ""
|
|
|
|
, preInstall ? ""
|
|
|
|
, postInstall ? ""
|
2024-09-19 14:19:46 +00:00
|
|
|
, installTargets ? if ((lib.versionOlder version "27.0") || ex_docSupport) then [ "install" "install-docs" ] else [ "install" ]
|
2021-06-04 09:07:49 +00:00
|
|
|
, checkPhase ? ""
|
|
|
|
, preCheck ? ""
|
|
|
|
, postCheck ? ""
|
|
|
|
, fixupPhase ? ""
|
|
|
|
, preFixup ? ""
|
|
|
|
, postFixup ? ""
|
|
|
|
, meta ? { }
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert wxSupport -> (if stdenv.isDarwin
|
2022-11-21 17:40:18 +00:00
|
|
|
then wxGTK != null
|
2021-06-04 09:07:49 +00:00
|
|
|
else libGL != null && libGLU != null && wxGTK != null && xorg != null);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
assert odbcSupport -> unixODBC != null;
|
2021-02-16 17:04:54 +00:00
|
|
|
assert javacSupport -> openjdk11 != null;
|
2024-09-19 14:19:46 +00:00
|
|
|
assert ex_docSupport -> ex_doc != null;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
2021-02-05 17:12:51 +00:00
|
|
|
inherit (lib) optional optionals optionalAttrs optionalString;
|
2022-11-21 17:40:18 +00:00
|
|
|
wxPackages2 = if stdenv.isDarwin then [ wxGTK ] else wxPackages;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-06-04 09:07:49 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation ({
|
2021-09-28 08:13:01 +00:00
|
|
|
# name is used instead of pname to
|
|
|
|
# - not have to pass pnames as argument
|
|
|
|
# - have a separate pname for erlang (main module)
|
|
|
|
name = "${baseName}"
|
|
|
|
+ optionalString javacSupport "_javac"
|
|
|
|
+ optionalString odbcSupport "_odbc"
|
|
|
|
+ "-${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
inherit src version;
|
|
|
|
|
|
|
|
nativeBuildInputs = [ autoconf makeWrapper perl gnum4 libxslt libxml2 ];
|
|
|
|
|
2021-02-17 17:02:09 +00:00
|
|
|
buildInputs = [ ncurses opensslPackage ]
|
2020-04-24 23:36:52 +00:00
|
|
|
++ optionals wxSupport wxPackages2
|
|
|
|
++ optionals odbcSupport odbcPackages
|
|
|
|
++ optionals javacSupport javacPackages
|
2021-09-18 10:52:07 +00:00
|
|
|
++ optional systemdSupport systemd
|
2021-03-09 03:18:52 +00:00
|
|
|
++ optionals stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [ AGL Carbon Cocoa WebKit ]);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
debugInfo = enableDebugInfo;
|
|
|
|
|
|
|
|
# On some machines, parallel build reliably crashes on `GEN asn1ct_eval_ext.erl` step
|
2020-07-18 16:06:22 +00:00
|
|
|
enableParallelBuilding = parallelBuild;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
patchShebangs make
|
|
|
|
|
|
|
|
${postPatch}
|
2024-06-20 14:57:18 +00:00
|
|
|
'' + optionalString (lib.versionOlder "25" version) ''
|
|
|
|
substituteInPlace lib/os_mon/src/disksup.erl \
|
|
|
|
--replace-fail '"sh ' '"${runtimeShell} '
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
# For OTP 27+ we need ex_doc to build the documentation
|
2024-09-19 14:19:46 +00:00
|
|
|
# When ex_docSupport is enabled, grab the raw ex_doc executable from the ex_doc
|
2024-04-21 15:54:59 +00:00
|
|
|
# derivation. Next, patch the first line to use the escript that will be
|
|
|
|
# built during the build phase of this derivation. Finally, building the
|
|
|
|
# documentation requires the erlang-logo.png asset.
|
2020-04-24 23:36:52 +00:00
|
|
|
preConfigure = ''
|
|
|
|
./otp_build autoconf
|
2024-09-19 14:19:46 +00:00
|
|
|
'' + optionalString ex_docSupport ''
|
2024-04-21 15:54:59 +00:00
|
|
|
mkdir -p $out/bin
|
2024-09-19 14:19:46 +00:00
|
|
|
cp ${ex_doc}/bin/.ex_doc-wrapped $out/bin/ex_doc
|
2024-04-21 15:54:59 +00:00
|
|
|
sed -i "1 s:^.*$:#!$out/bin/escript:" $out/bin/ex_doc
|
|
|
|
export EX_DOC=$out/bin/ex_doc
|
|
|
|
|
|
|
|
mkdir -p $out/lib/erlang/system/doc/assets
|
|
|
|
cp $src/system/doc/assets/erlang-logo.png $out/lib/erlang/system/doc/assets
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
configureFlags = [ "--with-ssl=${lib.getOutput "out" opensslPackage}" ]
|
|
|
|
++ [ "--with-ssl-incl=${lib.getDev opensslPackage}" ] # This flag was introduced in R24
|
2020-04-24 23:36:52 +00:00
|
|
|
++ 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"
|
2021-09-18 10:52:07 +00:00
|
|
|
++ optional systemdSupport "--enable-systemd"
|
2020-09-25 04:45:31 +00:00
|
|
|
++ optional stdenv.isDarwin "--enable-darwin-64bit"
|
2022-11-27 09:42:12 +00:00
|
|
|
# make[3]: *** [yecc.beam] Segmentation fault: 11
|
|
|
|
++ optional (stdenv.isDarwin && stdenv.isx86_64) "--disable-jit"
|
2020-09-25 04:45:31 +00:00
|
|
|
++ configureFlags;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# install-docs will generate and install manpages and html docs
|
|
|
|
# (PDFs are generated only when fop is available).
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
ln -s $out/lib/erlang/lib/erl_interface*/bin/erl_call $out/bin/erl_call
|
|
|
|
|
|
|
|
${postInstall}
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Some erlang bin/ scripts run sed and awk
|
|
|
|
postFixup = ''
|
|
|
|
wrapProgram $out/lib/erlang/bin/erl --prefix PATH ":" "${gnused}/bin/"
|
2021-02-05 17:12:51 +00:00
|
|
|
wrapProgram $out/lib/erlang/bin/start_erl --prefix PATH ":" "${lib.makeBinPath [ gnused gawk ]}"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-04-12 18:23:04 +00:00
|
|
|
passthru = {
|
|
|
|
updateScript =
|
|
|
|
let major = builtins.head (builtins.splitVersion version);
|
2021-06-04 09:07:49 +00:00
|
|
|
in
|
|
|
|
writeScript "update.sh" ''
|
|
|
|
#!${stdenv.shell}
|
|
|
|
set -ox errexit
|
|
|
|
PATH=${lib.makeBinPath [ common-updater-scripts coreutils git gnused ]}
|
2022-03-05 16:20:37 +00:00
|
|
|
latest=$(list-git-tags --url=https://github.com/erlang/otp.git | sed -n 's/^OTP-${major}/${major}/p' | sort -V | tail -1)
|
2021-06-04 09:07:49 +00:00
|
|
|
if [ "$latest" != "${version}" ]; then
|
|
|
|
nixpkgs="$(git rev-parse --show-toplevel)"
|
2023-03-24 00:07:29 +00:00
|
|
|
nix_file="$nixpkgs/pkgs/development/interpreters/erlang/${major}.nix"
|
2021-06-04 09:07:49 +00:00
|
|
|
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"
|
|
|
|
fi
|
|
|
|
'';
|
2021-04-12 18:23:04 +00:00
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; ({
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://www.erlang.org/";
|
|
|
|
downloadPage = "https://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;
|
2021-02-13 14:23:35 +00:00
|
|
|
maintainers = teams.beam.members;
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.asl20;
|
|
|
|
} // meta);
|
|
|
|
}
|
2021-06-04 09:07:49 +00:00
|
|
|
// optionalAttrs (preUnpack != "") { inherit preUnpack; }
|
|
|
|
// optionalAttrs (postUnpack != "") { inherit postUnpack; }
|
|
|
|
// optionalAttrs (patches != [ ]) { inherit patches; }
|
|
|
|
// optionalAttrs (prePatch != "") { inherit prePatch; }
|
|
|
|
// optionalAttrs (patchPhase != "") { inherit patchPhase; }
|
2020-04-24 23:36:52 +00:00
|
|
|
// optionalAttrs (configurePhase != "") { inherit configurePhase; }
|
2021-06-04 09:07:49 +00:00
|
|
|
// 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; }
|
2020-04-24 23:36:52 +00:00
|
|
|
)
|