nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 # options set through beam-packages
3 # systemd support for epmd only
4 systemdSupport ? null,
5 wxSupport ? true,
6
7 # options set by version specific files, e.g. 28.nix
8 version,
9 hash ? null,
10
11}:
12{
13 # overridable options
14 enableDebugInfo ? false,
15 enableHipe ? true,
16 enableKernelPoll ? true,
17 enableSmpSupport ? true,
18 enableThreads ? true,
19 javacSupport ? false,
20 odbcSupport ? false,
21 parallelBuild ? true,
22
23 fetchFromGitHub,
24 gawk,
25 gnum4,
26 gnused,
27 lib,
28 libGL,
29 libGLU,
30 libxml2,
31 libxslt,
32 makeWrapper,
33 ncurses,
34 nix-update-script,
35 openjdk11,
36 openssl,
37 perl,
38 runtimeShell,
39 stdenv,
40 systemd,
41 unixODBC,
42 wrapGAppsHook3,
43 wxGTK32,
44 libx11,
45 zlib,
46}:
47let
48 inherit (lib)
49 optional
50 optionals
51 optionalString
52 ;
53
54 wxPackages2 =
55 if stdenv.hostPlatform.isDarwin then
56 [ wxGTK32 ]
57 else
58 [
59 libGL
60 libGLU
61 wxGTK32
62 libx11
63 wrapGAppsHook3
64 ];
65
66 major = builtins.head (builtins.splitVersion version);
67
68 enableSystemd =
69 if (systemdSupport == null) then
70 lib.meta.availableOn stdenv.hostPlatform systemd
71 else
72 systemdSupport;
73
74 runtimePath = lib.makeBinPath [
75 gawk
76 gnused
77 ];
78in
79stdenv.mkDerivation {
80 pname = "erlang" + optionalString javacSupport "_javac" + optionalString odbcSupport "_odbc";
81 inherit version;
82
83 src = fetchFromGitHub {
84 owner = "erlang";
85 repo = "otp";
86 tag = "OTP-${version}";
87 inherit hash;
88 };
89
90 env = {
91 # only build man pages and shell/IDE docs
92 DOC_TARGETS = "man chunks";
93 LANG = "C.UTF-8";
94 };
95
96 nativeBuildInputs = [
97 makeWrapper
98 perl
99 gnum4
100 libxslt
101 libxml2
102 ];
103
104 buildInputs = [
105 ncurses
106 openssl
107 zlib
108 ]
109 ++ optionals wxSupport wxPackages2
110 ++ optionals odbcSupport [ unixODBC ]
111 ++ optionals javacSupport [ openjdk11 ]
112 ++ optionals enableSystemd [ systemd ];
113
114 # disksup requires a shell
115 postPatch = ''
116 substituteInPlace lib/os_mon/src/disksup.erl --replace-fail '"sh ' '"${runtimeShell} '
117 '';
118
119 debugInfo = enableDebugInfo;
120
121 # On some machines, parallel build reliably crashes on `GEN asn1ct_eval_ext.erl` step
122 enableParallelBuilding = parallelBuild;
123
124 configureFlags = [
125 "--with-ssl=${lib.getOutput "out" openssl}"
126 "--with-ssl-incl=${lib.getDev openssl}"
127 ]
128 ++ optional enableThreads "--enable-threads"
129 ++ optional enableSmpSupport "--enable-smp-support"
130 ++ optional enableKernelPoll "--enable-kernel-poll"
131 ++ optional enableHipe "--enable-hipe"
132 ++ optional javacSupport "--with-javac"
133 ++ optional odbcSupport "--with-odbc=${unixODBC}"
134 ++ optional wxSupport "--enable-wx"
135 ++ optional enableSystemd "--enable-systemd"
136 ++ optional stdenv.hostPlatform.isDarwin "--enable-darwin-64bit"
137 # make[3]: *** [yecc.beam] Segmentation fault: 11
138 ++ optional (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) "--disable-jit";
139
140 installTargets = [
141 "install"
142 "install-docs"
143 ];
144
145 postInstall = ''
146 ln -sv $out/lib/erlang/lib/erl_interface*/bin/erl_call $out/bin/erl_call
147
148 wrapProgram $out/lib/erlang/bin/erl --prefix PATH ":" "${runtimePath}"
149 wrapProgram $out/lib/erlang/bin/start_erl --prefix PATH ":" "${runtimePath}"
150 '';
151
152 passthru = {
153 updateScript = nix-update-script {
154 extraArgs = [
155 "--version-regex"
156 "OTP-(${major}.*)"
157 "--override-filename"
158 "pkgs/development/interpreters/erlang/${major}.nix"
159 ];
160 };
161 };
162
163 meta = {
164 homepage = "https://www.erlang.org/";
165 downloadPage = "https://www.erlang.org/download.html";
166 description = "Programming language used for massively scalable soft real-time systems";
167 changelog = "https://github.com/erlang/otp/releases/tag/OTP-${version}";
168
169 longDescription = ''
170 Erlang is a programming language used to build massively scalable
171 soft real-time systems with requirements on high availability.
172 Some of its uses are in telecoms, banking, e-commerce, computer
173 telephony and instant messaging. Erlang's runtime system has
174 built-in support for concurrency, distribution and fault
175 tolerance.
176 '';
177
178 platforms = lib.platforms.unix;
179 teams = [ lib.teams.beam ];
180 license = lib.licenses.asl20;
181 };
182}