@@ -1,21 +1,63 @@
11# pcre functionality is tested in nixos/tests/php-pcre.nix
2−
3−{ lib, stdenv, fetchurl, composableDerivation, flex, bison
4−, mysql, libxml2, readline, zlib, curl, postgresql, gettext, html-tidy
2+{ lib, stdenv, fetchurl, flex, bison
3+, mysql, libxml2, readline, zlib, curl, postgresql, gettext
54, openssl, pcre, pkgconfig, sqlite, config, libjpeg, libpng, freetype
65, libxslt, libmcrypt, bzip2, icu, openldap, cyrus_sasl, libmhash, freetds
7−, uwimap, pam, gmp, apacheHttpd, libiconv, systemd, libsodium }:
6+, uwimap, pam, gmp, apacheHttpd, libiconv, systemd, libsodium, html-tidy
7+}:
88
9−let
9+with lib;
1010
11+let
12+ php7 = versionAtLeast version "7.0";
1113 generic =
12− { version, sha256 }:
13−
14− let php7 = lib.versionAtLeast version "7.0";
15− mysqlndSupport = config.php.mysqlnd or false;
16− mysqlBuildInputs = lib.optional (!mysqlndSupport) mysql.connector-c;
17−
18− in composableDerivation.composableDerivation {} (fixed: {
14+ { version
15+ , sha256
16+ , imapSupport ? config.php.imap or (!stdenv.isDarwin)
17+ , ldapSupport ? config.php.ldap or true
18+ , mhashSupport ? config.php.mhash or true
19+ , mysqlSupport ? (config.php.mysql or true) && (!php7)
20+ , mysqlndSupport ? config.php.mysqlnd or false
21+ , mysqliSupport ? config.php.mysqli or true
22+ , pdo_mysqlSupport ? config.php.pdo_mysql or true
23+ , libxml2Support ? config.php.libxml2 or true
24+ , apxs2Support ? config.php.apxs2 or (!stdenv.isDarwin)
25+ , embedSupport ? config.php.embed or false
26+ , bcmathSupport ? config.php.bcmath or true
27+ , socketsSupport ? config.php.sockets or true
28+ , curlSupport ? config.php.curl or true
29+ , curlWrappersSupport ? (config.php.curlWrappers or true) && (!php7)
30+ , gettextSupport ? config.php.gettext or true
31+ , pcntlSupport ? config.php.pcntl or true
32+ , postgresqlSupport ? config.php.postgresql or true
33+ , pdo_pgsqlSupport ? config.php.pdo_pgsql or true
34+ , readlineSupport ? config.php.readline or true
35+ , sqliteSupport ? config.php.sqlite or true
36+ , soapSupport ? config.php.soap or true
37+ , zlibSupport ? config.php.zlib or true
38+ , opensslSupport ? config.php.openssl or true
39+ , mbstringSupport ? config.php.mbstring or true
40+ , gdSupport ? config.php.gd or true
41+ , intlSupport ? config.php.intl or true
42+ , exifSupport ? config.php.exif or true
43+ , xslSupport ? config.php.xsl or false
44+ , mcryptSupport ? config.php.mcrypt or true
45+ , bz2Support ? config.php.bz2 or false
46+ , zipSupport ? config.php.zip or true
47+ , ftpSupport ? config.php.ftp or true
48+ , fpmSupport ? config.php.fpm or true
49+ , gmpSupport ? config.php.gmp or true
50+ , mssqlSupport ? (config.php.mssql or (!stdenv.isDarwin)) && (!php7)
51+ , ztsSupport ? config.php.zts or false
52+ , calendarSupport ? config.php.calendar or true
53+ , sodiumSupport ? (config.php.sodium or true) && (versionAtLeast version "7.2")
54+ , tidySupport ? false
55+ }:
56+
57+ let
58+ mysqlBuildInputs = optional (!mysqlndSupport) mysql.connector-c;
59+ libmcrypt' = libmcrypt.override { disablePosixThreads = true; };
60+ in stdenv.mkDerivation {
1961
2062 inherit version;
2163
@@ -25,258 +67,99 @@ let
2567
2668 nativeBuildInputs = [ pkgconfig ];
2769 buildInputs = [ flex bison pcre ]
28− ++ lib.optional stdenv.isLinux systemd;
29−
30− CXXFLAGS = lib.optional stdenv.cc.isClang "-std=c++11";
31−
32− flags = {
33−
34− # much left to do here...
35−
36− # SAPI modules:
37−
38− apxs2 = {
39− configureFlags = ["--with-apxs2=${apacheHttpd.dev}/bin/apxs"];
40− buildInputs = [apacheHttpd];
41− };
42−
43− embed = {
44− configureFlags = ["--enable-embed"];
45− };
46−
47− # Extensions
48− imap = {
49− configureFlags = [
50− "--with-imap=${uwimap}"
51− "--with-imap-ssl"
52− ];
53− buildInputs = [ uwimap openssl pam ];
54− };
55−
56− ldap = {
57− configureFlags = [
58− "--with-ldap=/invalid/path"
59− "LDAP_DIR=${openldap.dev}"
60− "LDAP_INCDIR=${openldap.dev}/include"
61− "LDAP_LIBDIR=${openldap.out}/lib"
62− (lib.optional stdenv.isLinux "--with-ldap-sasl=${cyrus_sasl.dev}")
63− ];
64− buildInputs = [openldap openssl] ++ lib.optional stdenv.isLinux cyrus_sasl;
65− };
66−
67− mhash = {
68− configureFlags = ["--with-mhash"];
69− buildInputs = [libmhash];
70− };
71−
72− curl = {
73− configureFlags = ["--with-curl=${curl.dev}"];
74− buildInputs = [curl openssl];
75− };
76−
77− curlWrappers = {
78− configureFlags = ["--with-curlwrappers"];
79− };
80−
81− zlib = {
82− configureFlags = ["--with-zlib=${zlib.dev}"];
83− buildInputs = [zlib];
84− };
85−
86− libxml2 = {
87− configureFlags = [
88− "--with-libxml-dir=${libxml2.dev}"
89− ];
90− buildInputs = [ libxml2 ];
91− };
92−
93− pcntl = {
94− configureFlags = [ "--enable-pcntl" ];
95− };
96−
97− readline = {
98− configureFlags = ["--with-readline=${readline.dev}"];
99− buildInputs = [ readline ];
100− };
101−
102− sqlite = {
103− configureFlags = ["--with-pdo-sqlite=${sqlite.dev}"];
104− buildInputs = [ sqlite ];
105− };
106−
107− postgresql = {
108− configureFlags = ["--with-pgsql=${postgresql}"];
109− buildInputs = [ postgresql ];
110− };
111−
112− pdo_pgsql = {
113− configureFlags = ["--with-pdo-pgsql=${postgresql}"];
114− buildInputs = [ postgresql ];
115− };
116−
117− mysql = {
118− configureFlags = ["--with-mysql${if mysqlndSupport then "=mysqlnd" else ""}"];
119− buildInputs = mysqlBuildInputs;
120− };
121−
122− mysqli = {
123− configureFlags = ["--with-mysqli=${if mysqlndSupport then "mysqlnd" else "${mysql.connector-c}/bin/mysql_config"}"];
124− buildInputs = mysqlBuildInputs;
125− };
126−
127− mysqli_embedded = {
128− configureFlags = ["--enable-embedded-mysqli"];
129− depends = "mysqli";
130− assertion = fixed.mysqliSupport;
131− };
132−
133− pdo_mysql = {
134− configureFlags = ["--with-pdo-mysql=${if mysqlndSupport then "mysqlnd" else mysql.connector-c}"];
135− buildInputs = mysqlBuildInputs;
136− };
137−
138− bcmath = {
139− configureFlags = ["--enable-bcmath"];
140− };
70+ ++ optional stdenv.isLinux systemd
71+ ++ optionals imapSupport [ uwimap openssl pam ]
72+ ++ optionals curlSupport [ curl openssl ]
73+ ++ optionals ldapSupport [ openldap openssl ]
74+ ++ optionals gdSupport [ libpng libjpeg freetype ]
75+ ++ optionals opensslSupport [ openssl openssl.dev ]
76+ ++ optional apxs2Support apacheHttpd
77+ ++ optional (ldapSupport && stdenv.isLinux) cyrus_sasl
78+ ++ optional mhashSupport libmhash
79+ ++ optional zlibSupport zlib
80+ ++ optional libxml2Support libxml2
81+ ++ optional readlineSupport readline
82+ ++ optional sqliteSupport sqlite
83+ ++ optional postgresqlSupport postgresql
84+ ++ optional pdo_pgsqlSupport postgresql
85+ ++ optional pdo_mysqlSupport mysqlBuildInputs
86+ ++ optional mysqlSupport mysqlBuildInputs
87+ ++ optional mysqliSupport mysqlBuildInputs
88+ ++ optional gmpSupport gmp
89+ ++ optional gettextSupport gettext
90+ ++ optional intlSupport icu
91+ ++ optional xslSupport libxslt
92+ ++ optional mcryptSupport libmcrypt'
93+ ++ optional bz2Support bzip2
94+ ++ optional (mssqlSupport && !stdenv.isDarwin) freetds
95+ ++ optional sodiumSupport libsodium
96+ ++ optional tidySupport html-tidy;
97+
98+ CXXFLAGS = optional stdenv.cc.isClang "-std=c++11";
14199
142− gd = {
143− # FIXME: Our own gd package doesn't work, see https://bugs.php.net/bug.php?id=60108.
144− configureFlags = [
145− "--with-gd"
146− "--with-freetype-dir=${freetype.dev}"
147− "--with-png-dir=${libpng.dev}"
148− "--with-jpeg-dir=${libjpeg.dev}"
149− ];
150− buildInputs = [ libpng libjpeg freetype ];
151− };
152100
153− gmp = {
154− configureFlags = ["--with-gmp=${gmp.dev}"];
155− buildInputs = [ gmp ];
156− };
157−
158− soap = {
159− configureFlags = ["--enable-soap"];
160− };
161−
162− sockets = {
163− configureFlags = ["--enable-sockets"];
164− };
165−
166− openssl = {
167− configureFlags = ["--with-openssl"];
168− buildInputs = [openssl openssl.dev];
169− };
170−
171− mbstring = {
172− configureFlags = ["--enable-mbstring"];
173− };
174−
175− gettext = {
176− configureFlags = ["--with-gettext=${gettext}"];
177− buildInputs = [gettext];
178− };
179−
180− intl = {
181− configureFlags = ["--enable-intl"];
182− buildInputs = [icu];
183− };
184−
185− exif = {
186− configureFlags = ["--enable-exif"];
187− };
188−
189− xsl = {
190− configureFlags = ["--with-xsl=${libxslt.dev}"];
191− buildInputs = [libxslt];
192− };
193−
194− mcrypt = let libmcrypt' = libmcrypt.override { disablePosixThreads = true; }; in {
195− configureFlags = ["--with-mcrypt=${libmcrypt'}"];
196− buildInputs = [libmcrypt'];
197− };
198−
199− bz2 = {
200− configureFlags = ["--with-bz2=${bzip2.dev}"];
201− buildInputs = [bzip2];
202− };
203−
204− zip = {
205− configureFlags = ["--enable-zip"];
206− };
207−
208− ftp = {
209− configureFlags = ["--enable-ftp"];
210− };
211−
212− fpm = {
213− configureFlags = ["--enable-fpm"];
214− };
215−
216− mssql = stdenv.lib.optionalAttrs (!stdenv.isDarwin) {
217− configureFlags = ["--with-mssql=${freetds}"];
218− buildInputs = [freetds];
219− };
220−
221− zts = {
222− configureFlags = ["--enable-maintainer-zts"];
223− };
224−
225− calendar = {
226− configureFlags = ["--enable-calendar"];
227− };
228−
229− sodium = {
230− configureFlags = ["--with-sodium=${libsodium.dev}"];
231− buildInputs = [libsodium];
232− };
233−
234− tidy = {
235− configureFlags = [ "--with-tidy=${html-tidy}" ];
236− buildInputs = [ html-tidy ];
237− };
238− };
101+ configureFlags = [
102+ "--with-config-file-scan-dir=/etc/php.d"
103+ "--with-pcre-regex=${pcre.dev} PCRE_LIBDIR=${pcre}"
104+ ]
105+ ++ optional stdenv.isDarwin "--with-iconv=${libiconv}"
106+ ++ optional stdenv.isLinux "--with-fpm-systemd"
107+ ++ optionals imapSupport [
108+ "--with-imap=${uwimap}"
109+ "--with-imap-ssl"
110+ ]
111+ ++ optionals ldapSupport [
112+ "--with-ldap=/invalid/path"
113+ "LDAP_DIR=${openldap.dev}"
114+ "LDAP_INCDIR=${openldap.dev}/include"
115+ "LDAP_LIBDIR=${openldap.out}/lib"
116+ ]
117+ ++ optional (ldapSupport && stdenv.isLinux) "--with-ldap-sasl=${cyrus_sasl.dev}"
118+ ++ optional apxs2Support "--with-apxs2=${apacheHttpd.dev}/bin/apxs"
119+ ++ optional embedSupport "--enable-embed"
120+ ++ optional mhashSupport "--with-mhash"
121+ ++ optional curlSupport "--with-curl=${curl.dev}"
122+ ++ optional curlWrappersSupport "--with-curlwrappers"
123+ ++ optional zlibSupport "--with-zlib=${zlib.dev}"
124+ ++ optional libxml2Support "--with-libxml-dir=${libxml2.dev}"
125+ ++ optional pcntlSupport "--enable-pcntl"
126+ ++ optional readlineSupport "--with-readline=${readline.dev}"
127+ ++ optional sqliteSupport "--with-pdo-sqlite=${sqlite.dev}"
128+ ++ optional postgresqlSupport "--with-pgsql=${postgresql}"
129+ ++ optional pdo_pgsqlSupport "--with-pdo-pgsql=${postgresql}"
130+ ++ optional pdo_mysqlSupport "--with-pdo-mysql=${if mysqlndSupport then "mysqlnd" else mysql.connector-c}"
131+ ++ optional mysqlSupport "--with-mysql${if mysqlndSupport then "=mysqlnd" else ""}"
132+ ++ optionals mysqliSupport [
133+ "--with-mysqli=${if mysqlndSupport then "mysqlnd" else "${mysql.connector-c}/bin/mysql_config"}"
134+ ]
135+ ++ optional bcmathSupport "--enable-bcmath"
136+ # FIXME: Our own gd package doesn't work, see https://bugs.php.net/bug.php?id=60108.
137+ ++ optionals gdSupport [
138+ "--with-gd"
139+ "--with-freetype-dir=${freetype.dev}"
140+ "--with-png-dir=${libpng.dev}"
141+ "--with-jpeg-dir=${libjpeg.dev}"
142+ ]
143+ ++ optional gmpSupport "--with-gmp=${gmp.dev}"
144+ ++ optional soapSupport "--enable-soap"
145+ ++ optional socketsSupport "--enable-sockets"
146+ ++ optional opensslSupport "--with-openssl"
147+ ++ optional mbstringSupport "--enable-mbstring"
148+ ++ optional gettextSupport "--with-gettext=${gettext}"
149+ ++ optional intlSupport "--enable-intl"
150+ ++ optional exifSupport "--enable-exif"
151+ ++ optional xslSupport "--with-xsl=${libxslt.dev}"
152+ ++ optional mcryptSupport "--with-mcrypt=${libmcrypt'}"
153+ ++ optional bz2Support "--with-bz2=${bzip2.dev}"
154+ ++ optional zipSupport "--enable-zip"
155+ ++ optional ftpSupport "--enable-ftp"
156+ ++ optional fpmSupport "--enable-fpm"
157+ ++ optional (mssqlSupport && !stdenv.isDarwin) "--with-mssql=${freetds}"
158+ ++ optional ztsSupport "--enable-maintainer-zts"
159+ ++ optional calendarSupport "--enable-calendar"
160+ ++ optional sodiumSupport "--with-sodium=${libsodium.dev}"
161+ ++ optional tidySupport "--with-tidy=${html-tidy}";
239162
240− cfg = {
241− imapSupport = config.php.imap or (!stdenv.isDarwin);
242− ldapSupport = config.php.ldap or true;
243− mhashSupport = config.php.mhash or true;
244− mysqlSupport = (!php7) && (config.php.mysql or true);
245− mysqliSupport = config.php.mysqli or true;
246− pdo_mysqlSupport = config.php.pdo_mysql or true;
247− libxml2Support = config.php.libxml2 or true;
248− apxs2Support = config.php.apxs2 or (!stdenv.isDarwin);
249− embedSupport = config.php.embed or false;
250− bcmathSupport = config.php.bcmath or true;
251− socketsSupport = config.php.sockets or true;
252− curlSupport = config.php.curl or true;
253− curlWrappersSupport = (!php7) && (config.php.curlWrappers or true);
254− gettextSupport = config.php.gettext or true;
255− pcntlSupport = config.php.pcntl or true;
256− postgresqlSupport = config.php.postgresql or true;
257− pdo_pgsqlSupport = config.php.pdo_pgsql or true;
258− readlineSupport = config.php.readline or true;
259− sqliteSupport = config.php.sqlite or true;
260− soapSupport = config.php.soap or true;
261− zlibSupport = config.php.zlib or true;
262− opensslSupport = config.php.openssl or true;
263− mbstringSupport = config.php.mbstring or true;
264− gdSupport = config.php.gd or true;
265− intlSupport = config.php.intl or true;
266− exifSupport = config.php.exif or true;
267− xslSupport = config.php.xsl or false;
268− mcryptSupport = config.php.mcrypt or true;
269− bz2Support = config.php.bz2 or false;
270− zipSupport = config.php.zip or true;
271− ftpSupport = config.php.ftp or true;
272− fpmSupport = config.php.fpm or true;
273− gmpSupport = config.php.gmp or true;
274− mssqlSupport = (!php7) && (config.php.mssql or (!stdenv.isDarwin));
275− ztsSupport = config.php.zts or false;
276− calendarSupport = config.php.calendar or true;
277− sodiumSupport = (lib.versionAtLeast version "7.2") && config.php.sodium or true;
278− tidySupport = php7 && config.php.tidy or true;
279− };
280163
281164 hardeningDisable = [ "bindnow" ];
282165
@@ -298,12 +181,6 @@ let
298181 --includedir=$dev/include)
299182 '';
300183
301− configureFlags = [
302− "--with-config-file-scan-dir=/etc/php.d"
303− "--with-pcre-regex=${pcre.dev} PCRE_LIBDIR=${pcre}"
304− ] ++ lib.optional stdenv.isDarwin "--with-iconv=${libiconv}"
305− ++ lib.optional stdenv.isLinux "--with-fpm-systemd";
306−
307184 postInstall = ''
308185 cp php.ini-production $out/etc/php.ini
309186 '';
@@ -332,7 +209,7 @@ let
332209
333210 patches = if !php7 then [ ./fix-paths.patch ] else [ ./fix-paths-php7.patch ];
334211
335− postPatch = lib.optional stdenv.isDarwin ''
212+ postPatch = optional stdenv.isDarwin ''
336213 substituteInPlace configure --replace "-lstdc++" "-lc++"
337214 '';
338215
@@ -340,7 +217,7 @@ let
340217
341218 outputs = [ "out" "dev" ];
342219
343− });
220+ };
344221
345222in {
346223 php56 = generic {