1{ lib, stdenv, fetchurl, composableDerivation, autoconf, automake, flex, bison
2, mysql, libxml2, readline, zlib, curl, postgresql, gettext
3, openssl, pkgconfig, sqlite, config, libjpeg, libpng, freetype
4, libxslt, libmcrypt, bzip2, icu, openldap, cyrus_sasl, libmhash, freetds
5, uwimap, pam, gmp, apacheHttpd }:
6
7let
8
9 generic =
10 { version, sha256, url ? "http://www.php.net/distributions/php-${version}.tar.bz2" }:
11
12 let php7 = lib.versionAtLeast version "7.0"; in
13
14 composableDerivation.composableDerivation {} (fixed: {
15
16 inherit version;
17
18 name = "php-${version}";
19
20 enableParallelBuilding = true;
21
22 buildInputs = [ flex bison pkgconfig ];
23
24 flags = {
25
26 # much left to do here...
27
28 # SAPI modules:
29
30 apxs2 = {
31 configureFlags = ["--with-apxs2=${apacheHttpd}/bin/apxs"];
32 buildInputs = [apacheHttpd];
33 };
34
35 # Extensions
36 imap = {
37 configureFlags = [
38 "--with-imap=${uwimap}"
39 "--with-imap-ssl"
40 ];
41 buildInputs = [ uwimap openssl pam ];
42 };
43
44 ldap = {
45 configureFlags = ["--with-ldap=${openldap}"];
46 buildInputs = [openldap cyrus_sasl openssl];
47 };
48
49 mhash = {
50 configureFlags = ["--with-mhash"];
51 buildInputs = [libmhash];
52 };
53
54 curl = {
55 configureFlags = ["--with-curl=${curl}"];
56 buildInputs = [curl openssl];
57 };
58
59 curlWrappers = {
60 configureFlags = ["--with-curlwrappers"];
61 };
62
63 zlib = {
64 configureFlags = ["--with-zlib=${zlib}"];
65 buildInputs = [zlib];
66 };
67
68 libxml2 = {
69 configureFlags = [
70 "--with-libxml-dir=${libxml2}"
71 ];
72 buildInputs = [ libxml2 ];
73 };
74
75 pcntl = {
76 configureFlags = [ "--enable-pcntl" ];
77 };
78
79 readline = {
80 configureFlags = ["--with-readline=${readline}"];
81 buildInputs = [ readline ];
82 };
83
84 sqlite = {
85 configureFlags = ["--with-pdo-sqlite=${sqlite}"];
86 buildInputs = [ sqlite ];
87 };
88
89 postgresql = {
90 configureFlags = ["--with-pgsql=${postgresql}"];
91 buildInputs = [ postgresql ];
92 };
93
94 pdo_pgsql = {
95 configureFlags = ["--with-pdo-pgsql=${postgresql}"];
96 buildInputs = [ postgresql ];
97 };
98
99 mysql = {
100 configureFlags = ["--with-mysql=${mysql.lib}"];
101 buildInputs = [ mysql.lib ];
102 };
103
104 mysqli = {
105 configureFlags = ["--with-mysqli=${mysql.lib}/bin/mysql_config"];
106 buildInputs = [ mysql.lib ];
107 };
108
109 mysqli_embedded = {
110 configureFlags = ["--enable-embedded-mysqli"];
111 depends = "mysqli";
112 assertion = fixed.mysqliSupport;
113 };
114
115 pdo_mysql = {
116 configureFlags = ["--with-pdo-mysql=${mysql.lib}"];
117 buildInputs = [ mysql.lib ];
118 };
119
120 bcmath = {
121 configureFlags = ["--enable-bcmath"];
122 };
123
124 gd = {
125 # FIXME: Our own gd package doesn't work, see https://bugs.php.net/bug.php?id=60108.
126 configureFlags = [
127 "--with-gd"
128 "--with-freetype-dir=${freetype}"
129 "--with-png-dir=${libpng}"
130 "--with-jpeg-dir=${libjpeg}"
131 ];
132 buildInputs = [ libpng libjpeg freetype ];
133 };
134
135 gmp = {
136 configureFlags = ["--with-gmp=${gmp}"];
137 buildInputs = [ gmp ];
138 };
139
140 soap = {
141 configureFlags = ["--enable-soap"];
142 };
143
144 sockets = {
145 configureFlags = ["--enable-sockets"];
146 };
147
148 openssl = {
149 configureFlags = ["--with-openssl=${openssl}"];
150 buildInputs = [openssl];
151 };
152
153 mbstring = {
154 configureFlags = ["--enable-mbstring"];
155 };
156
157 gettext = {
158 configureFlags = ["--with-gettext=${gettext}"];
159 buildInputs = [gettext];
160 };
161
162 intl = {
163 configureFlags = ["--enable-intl"];
164 buildInputs = [icu];
165 };
166
167 exif = {
168 configureFlags = ["--enable-exif"];
169 };
170
171 xsl = {
172 configureFlags = ["--with-xsl=${libxslt}"];
173 buildInputs = [libxslt];
174 };
175
176 mcrypt = let libmcrypt' = libmcrypt.override { disablePosixThreads = true; }; in {
177 configureFlags = ["--with-mcrypt=${libmcrypt'}"];
178 buildInputs = [libmcrypt'];
179 };
180
181 bz2 = {
182 configureFlags = ["--with-bz2=${bzip2}"];
183 buildInputs = [bzip2];
184 };
185
186 zip = {
187 configureFlags = ["--enable-zip"];
188 };
189
190 ftp = {
191 configureFlags = ["--enable-ftp"];
192 };
193
194 fpm = {
195 configureFlags = ["--enable-fpm"];
196 };
197
198 mssql = stdenv.lib.optionalAttrs (!stdenv.isDarwin) {
199 configureFlags = ["--with-mssql=${freetds}"];
200 buildInputs = [freetds];
201 };
202
203 zts = {
204 configureFlags = ["--enable-maintainer-zts"];
205 };
206
207 calendar = {
208 configureFlags = ["--enable-calendar"];
209 };
210 };
211
212 cfg = {
213 imapSupport = config.php.imap or true;
214 ldapSupport = config.php.ldap or true;
215 mhashSupport = config.php.mhash or true;
216 mysqlSupport = (!php7) && (config.php.mysql or true);
217 mysqliSupport = config.php.mysqli or true;
218 pdo_mysqlSupport = config.php.pdo_mysql or true;
219 libxml2Support = config.php.libxml2 or true;
220 apxs2Support = config.php.apxs2 or true;
221 bcmathSupport = config.php.bcmath or true;
222 socketsSupport = config.php.sockets or true;
223 curlSupport = config.php.curl or true;
224 curlWrappersSupport = (!php7) && (config.php.curlWrappers or true);
225 gettextSupport = config.php.gettext or true;
226 pcntlSupport = config.php.pcntl or true;
227 postgresqlSupport = config.php.postgresql or true;
228 pdo_pgsqlSupport = config.php.pdo_pgsql or true;
229 readlineSupport = config.php.readline or true;
230 sqliteSupport = config.php.sqlite or true;
231 soapSupport = config.php.soap or true;
232 zlibSupport = config.php.zlib or true;
233 opensslSupport = config.php.openssl or true;
234 mbstringSupport = config.php.mbstring or true;
235 gdSupport = config.php.gd or true;
236 intlSupport = config.php.intl or true;
237 exifSupport = config.php.exif or true;
238 xslSupport = config.php.xsl or false;
239 mcryptSupport = config.php.mcrypt or true;
240 bz2Support = config.php.bz2 or false;
241 zipSupport = config.php.zip or true;
242 ftpSupport = config.php.ftp or true;
243 fpmSupport = config.php.fpm or true;
244 gmpSupport = config.php.gmp or true;
245 mssqlSupport = (!php7) && (config.php.mssql or (!stdenv.isDarwin));
246 ztsSupport = config.php.zts or false;
247 calendarSupport = config.php.calendar or true;
248 };
249
250 configurePhase = ''
251 # Don't record the configure flags since this causes unnecessary
252 # runtime dependencies.
253 for i in main/build-defs.h.in scripts/php-config.in; do
254 substituteInPlace $i \
255 --replace '@CONFIGURE_COMMAND@' '(omitted)' \
256 --replace '@CONFIGURE_OPTIONS@' "" \
257 --replace '@PHP_LDFLAGS@' ""
258 done
259
260 iniFile=$out/etc/php-recommended.ini
261 [[ -z "$libxml2" ]] || export PATH=$PATH:$libxml2/bin
262 ./configure --with-config-file-scan-dir=/etc --with-config-file-path=$out/etc --prefix=$out $configureFlags
263 '';
264
265 installPhase = ''
266 unset installPhase; installPhase;
267 cp php.ini-production $iniFile
268 '';
269
270 src = fetchurl {
271 inherit url sha256;
272 };
273
274 meta = with stdenv.lib; {
275 description = "An HTML-embedded scripting language";
276 homepage = http://www.php.net/;
277 license = stdenv.lib.licenses.php301;
278 maintainers = with maintainers; [ globin ];
279 };
280
281 patches = if !php7 then [ ./fix-paths.patch ] else [ ./fix-paths-php7.patch ];
282
283 });
284
285in {
286
287 php54 = generic {
288 version = "5.4.45";
289 sha256 = "10k59j7zjx2mrldmgfvjrrcg2cslr2m68azslspcz5acanqjh3af";
290 };
291
292 php55 = generic {
293 version = "5.5.29";
294 sha256 = "0imr8c48ffjhc2zm96ndq92z3736xrm12hd5c1lssz67xiwybkpv";
295 };
296
297 php56 = generic {
298 version = "5.6.13";
299 sha256 = "14zq40j229salk0wp7inl4jvj3xff03bz7g5xn8ipd5skiy86n33";
300 };
301
302 php70 = lib.lowPrio (generic {
303 version = "7.0.0beta1";
304 url = "https://downloads.php.net/~ab/php-7.0.0beta1.tar.bz2";
305 sha256 = "1pj3ysfhswg2r370ivp33fv9zbcl3yvhmxgnc731k08hv6hmd984";
306 });
307
308}