15 , openjdk11 ? null # javacSupport
16 , unixODBC ? null # odbcSupport
21 , parallelBuild ? false
24 , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd # systemd support in epmd
27 , common-updater-scripts
34 , rev ? "OTP-${version}"
35 , src ? fetchFromGitHub { inherit rev sha256; owner = "erlang"; repo = "otp"; }
37 , enableDebugInfo ? false
38 , enableThreads ? true
39 , enableSmpSupport ? true
40 , enableKernelPoll ? true
41 , javacSupport ? false
42 , javacPackages ? [ openjdk11 ]
44 , odbcPackages ? [ unixODBC ]
45 , opensslPackage ? openssl
46 , wxPackages ? [ libGL libGLU wxGTK xorg.libX11 ]
53 , configureFlags ? [ ]
63 , installTargets ? [ "install" "install-docs" ]
73 assert wxSupport -> (if stdenv.isDarwin
75 else libGL != null && libGLU != null && wxGTK != null && xorg != null);
77 assert odbcSupport -> unixODBC != null;
78 assert javacSupport -> openjdk11 != null;
81 inherit (lib) optional optionals optionalAttrs optionalString;
82 wxPackages2 = if stdenv.isDarwin then [ wxGTK ] else wxPackages;
85 stdenv.mkDerivation ({
86 # name is used instead of pname to
87 # - not have to pass pnames as argument
88 # - have a separate pname for erlang (main module)
90 + optionalString javacSupport "_javac"
91 + optionalString odbcSupport "_odbc"
96 nativeBuildInputs = [ autoconf makeWrapper perl gnum4 libxslt libxml2 ];
98 buildInputs = [ ncurses opensslPackage ]
99 ++ optionals wxSupport wxPackages2
100 ++ optionals odbcSupport odbcPackages
101 ++ optionals javacSupport javacPackages
102 ++ optional systemdSupport systemd
103 ++ optionals stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [ AGL Carbon Cocoa WebKit ]);
105 debugInfo = enableDebugInfo;
107 # On some machines, parallel build reliably crashes on `GEN asn1ct_eval_ext.erl` step
108 enableParallelBuilding = parallelBuild;
120 configureFlags = [ "--with-ssl=${lib.getOutput "out" opensslPackage}" ]
121 ++ [ "--with-ssl-incl=${lib.getDev opensslPackage}" ] # This flag was introduced in R24
122 ++ optional enableThreads "--enable-threads"
123 ++ optional enableSmpSupport "--enable-smp-support"
124 ++ optional enableKernelPoll "--enable-kernel-poll"
125 ++ optional enableHipe "--enable-hipe"
126 ++ optional javacSupport "--with-javac"
127 ++ optional odbcSupport "--with-odbc=${unixODBC}"
128 ++ optional wxSupport "--enable-wx"
129 ++ optional systemdSupport "--enable-systemd"
130 ++ optional stdenv.isDarwin "--enable-darwin-64bit"
131 # make[3]: *** [yecc.beam] Segmentation fault: 11
132 ++ optional (stdenv.isDarwin && stdenv.isx86_64) "--disable-jit"
135 # install-docs will generate and install manpages and html docs
136 # (PDFs are generated only when fop is available).
139 ln -s $out/lib/erlang/lib/erl_interface*/bin/erl_call $out/bin/erl_call
144 # Some erlang bin/ scripts run sed and awk
146 wrapProgram $out/lib/erlang/bin/erl --prefix PATH ":" "${gnused}/bin/"
147 wrapProgram $out/lib/erlang/bin/start_erl --prefix PATH ":" "${lib.makeBinPath [ gnused gawk ]}"
152 let major = builtins.head (builtins.splitVersion version);
154 writeScript "update.sh" ''
157 PATH=${lib.makeBinPath [ common-updater-scripts coreutils git gnused ]}
158 latest=$(list-git-tags --url=https://github.com/erlang/otp.git | sed -n 's/^OTP-${major}/${major}/p' | sort -V | tail -1)
159 if [ "$latest" != "${version}" ]; then
160 nixpkgs="$(git rev-parse --show-toplevel)"
161 nix_file="$nixpkgs/pkgs/development/interpreters/erlang/${major}.nix"
162 update-source-version ${baseName}R${major} "$latest" --version-key=version --print-changes --file="$nix_file"
164 echo "${baseName}R${major} is already up-to-date"
170 homepage = "https://www.erlang.org/";
171 downloadPage = "https://www.erlang.org/download.html";
172 description = "Programming language used for massively scalable soft real-time systems";
175 Erlang is a programming language used to build massively scalable
176 soft real-time systems with requirements on high availability.
177 Some of its uses are in telecoms, banking, e-commerce, computer
178 telephony and instant messaging. Erlang's runtime system has
179 built-in support for concurrency, distribution and fault
183 platforms = platforms.unix;
184 maintainers = teams.beam.members;
185 license = licenses.asl20;
188 // optionalAttrs (preUnpack != "") { inherit preUnpack; }
189 // optionalAttrs (postUnpack != "") { inherit postUnpack; }
190 // optionalAttrs (patches != [ ]) { inherit patches; }
191 // optionalAttrs (prePatch != "") { inherit prePatch; }
192 // optionalAttrs (patchPhase != "") { inherit patchPhase; }
193 // optionalAttrs (configurePhase != "") { inherit configurePhase; }
194 // optionalAttrs (preConfigure != "") { inherit preConfigure; }
195 // optionalAttrs (postConfigure != "") { inherit postConfigure; }
196 // optionalAttrs (buildPhase != "") { inherit buildPhase; }
197 // optionalAttrs (preBuild != "") { inherit preBuild; }
198 // optionalAttrs (postBuild != "") { inherit postBuild; }
199 // optionalAttrs (checkPhase != "") { inherit checkPhase; }
200 // optionalAttrs (preCheck != "") { inherit preCheck; }
201 // optionalAttrs (postCheck != "") { inherit postCheck; }
202 // optionalAttrs (installPhase != "") { inherit installPhase; }
203 // optionalAttrs (installTargets != [ ]) { inherit installTargets; }
204 // optionalAttrs (preInstall != "") { inherit preInstall; }
205 // optionalAttrs (fixupPhase != "") { inherit fixupPhase; }
206 // optionalAttrs (preFixup != "") { inherit preFixup; }
207 // optionalAttrs (postFixup != "") { inherit postFixup; }