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