16 , openjdk11 ? null # javacSupport
17 , unixODBC ? null # odbcSupport
23 , parallelBuild ? false
26 , ex_docSupport ? false
27 , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd # systemd support in epmd
30 , common-updater-scripts
38 , rev ? "OTP-${version}"
39 , src ? fetchFromGitHub { inherit rev sha256; owner = "erlang"; repo = "otp"; }
41 , enableDebugInfo ? false
42 , enableThreads ? true
43 , enableSmpSupport ? true
44 , enableKernelPoll ? true
45 , javacSupport ? false
46 , javacPackages ? [ openjdk11 ]
48 , odbcPackages ? [ unixODBC ]
49 , opensslPackage ? openssl
50 , wxPackages ? [ libGL libGLU wxGTK xorg.libX11 wrapGAppsHook3 ]
57 , configureFlags ? [ ]
67 , installTargets ? if ((lib.versionOlder version "27.0") || ex_docSupport) then [ "install" "install-docs" ] else [ "install" ]
77 assert wxSupport -> (if stdenv.hostPlatform.isDarwin
79 else libGL != null && libGLU != null && wxGTK != null && xorg != null);
81 assert odbcSupport -> unixODBC != null;
82 assert javacSupport -> openjdk11 != null;
83 assert ex_docSupport -> ex_doc != null;
86 inherit (lib) optional optionals optionalAttrs optionalString;
87 wxPackages2 = if stdenv.hostPlatform.isDarwin then [ wxGTK ] else wxPackages;
90 stdenv.mkDerivation ({
91 # name is used instead of pname to
92 # - not have to pass pnames as argument
93 # - have a separate pname for erlang (main module)
95 + optionalString javacSupport "_javac"
96 + optionalString odbcSupport "_odbc"
103 nativeBuildInputs = [ autoconf makeWrapper perl gnum4 libxslt libxml2 ];
105 buildInputs = [ ncurses opensslPackage ]
106 ++ optionals wxSupport wxPackages2
107 ++ optionals odbcSupport odbcPackages
108 ++ optionals javacSupport javacPackages
109 ++ optional systemdSupport systemd
110 ++ optionals stdenv.hostPlatform.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [ AGL Carbon Cocoa WebKit ]);
112 debugInfo = enableDebugInfo;
114 # On some machines, parallel build reliably crashes on `GEN asn1ct_eval_ext.erl` step
115 enableParallelBuilding = parallelBuild;
121 '' + optionalString (lib.versionOlder "25" version) ''
122 substituteInPlace lib/os_mon/src/disksup.erl \
123 --replace-fail '"sh ' '"${runtimeShell} '
126 # For OTP 27+ we need ex_doc to build the documentation
127 # When ex_docSupport is enabled, grab the raw ex_doc executable from the ex_doc
128 # derivation. Next, patch the first line to use the escript that will be
129 # built during the build phase of this derivation. Finally, building the
130 # documentation requires the erlang-logo.png asset.
133 '' + optionalString ex_docSupport ''
135 cp ${ex_doc}/bin/.ex_doc-wrapped $out/bin/ex_doc
136 sed -i "1 s:^.*$:#!$out/bin/escript:" $out/bin/ex_doc
137 export EX_DOC=$out/bin/ex_doc
139 mkdir -p $out/lib/erlang/system/doc/assets
140 cp $src/system/doc/assets/erlang-logo.png $out/lib/erlang/system/doc/assets
143 configureFlags = [ "--with-ssl=${lib.getOutput "out" opensslPackage}" ]
144 ++ [ "--with-ssl-incl=${lib.getDev opensslPackage}" ] # This flag was introduced in R24
145 ++ optional enableThreads "--enable-threads"
146 ++ optional enableSmpSupport "--enable-smp-support"
147 ++ optional enableKernelPoll "--enable-kernel-poll"
148 ++ optional enableHipe "--enable-hipe"
149 ++ optional javacSupport "--with-javac"
150 ++ optional odbcSupport "--with-odbc=${unixODBC}"
151 ++ optional wxSupport "--enable-wx"
152 ++ optional systemdSupport "--enable-systemd"
153 ++ optional stdenv.hostPlatform.isDarwin "--enable-darwin-64bit"
154 # make[3]: *** [yecc.beam] Segmentation fault: 11
155 ++ optional (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) "--disable-jit"
158 # install-docs will generate and install manpages and html docs
159 # (PDFs are generated only when fop is available).
162 ln -s $out/lib/erlang/lib/erl_interface*/bin/erl_call $out/bin/erl_call
167 # Some erlang bin/ scripts run sed and awk
169 wrapProgram $out/lib/erlang/bin/erl --prefix PATH ":" "${gnused}/bin/"
170 wrapProgram $out/lib/erlang/bin/start_erl --prefix PATH ":" "${lib.makeBinPath [ gnused gawk ]}"
175 let major = builtins.head (builtins.splitVersion version);
177 writeScript "update.sh" ''
180 PATH=${lib.makeBinPath [ common-updater-scripts coreutils git gnused ]}
181 latest=$(list-git-tags --url=https://github.com/erlang/otp.git | sed -n 's/^OTP-${major}/${major}/p' | sort -V | tail -1)
182 if [ "$latest" != "${version}" ]; then
183 nixpkgs="$(git rev-parse --show-toplevel)"
184 nix_file="$nixpkgs/pkgs/development/interpreters/erlang/${major}.nix"
185 update-source-version ${baseName}R${major} "$latest" --version-key=version --print-changes --file="$nix_file"
187 echo "${baseName}R${major} is already up-to-date"
193 homepage = "https://www.erlang.org/";
194 downloadPage = "https://www.erlang.org/download.html";
195 description = "Programming language used for massively scalable soft real-time systems";
198 Erlang is a programming language used to build massively scalable
199 soft real-time systems with requirements on high availability.
200 Some of its uses are in telecoms, banking, e-commerce, computer
201 telephony and instant messaging. Erlang's runtime system has
202 built-in support for concurrency, distribution and fault
206 platforms = platforms.unix;
207 maintainers = teams.beam.members;
208 license = licenses.asl20;
211 // optionalAttrs (preUnpack != "") { inherit preUnpack; }
212 // optionalAttrs (postUnpack != "") { inherit postUnpack; }
213 // optionalAttrs (patches != [ ]) { inherit patches; }
214 // optionalAttrs (prePatch != "") { inherit prePatch; }
215 // optionalAttrs (patchPhase != "") { inherit patchPhase; }
216 // optionalAttrs (configurePhase != "") { inherit configurePhase; }
217 // optionalAttrs (preConfigure != "") { inherit preConfigure; }
218 // optionalAttrs (postConfigure != "") { inherit postConfigure; }
219 // optionalAttrs (buildPhase != "") { inherit buildPhase; }
220 // optionalAttrs (preBuild != "") { inherit preBuild; }
221 // optionalAttrs (postBuild != "") { inherit postBuild; }
222 // optionalAttrs (checkPhase != "") { inherit checkPhase; }
223 // optionalAttrs (preCheck != "") { inherit preCheck; }
224 // optionalAttrs (postCheck != "") { inherit postCheck; }
225 // optionalAttrs (installPhase != "") { inherit installPhase; }
226 // optionalAttrs (installTargets != [ ]) { inherit installTargets; }
227 // optionalAttrs (preInstall != "") { inherit preInstall; }
228 // optionalAttrs (fixupPhase != "") { inherit fixupPhase; }
229 // optionalAttrs (preFixup != "") { inherit preFixup; }
230 // optionalAttrs (postFixup != "") { inherit postFixup; }