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