Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-18.03 362 lines 11 kB view raw
1# pcre functionality is tested in nixos/tests/php-pcre.nix 2 3{ lib, stdenv, fetchurl, composableDerivation, autoconf, automake, flex, bison 4, mysql, libxml2, readline, zlib, curl, postgresql, gettext 5, openssl, pcre, pkgconfig, sqlite, config, libjpeg, libpng, freetype 6, libxslt, libmcrypt, bzip2, icu, openldap, cyrus_sasl, libmhash, freetds 7, uwimap, pam, gmp, apacheHttpd, libiconv, systemd, libsodium }: 8 9let 10 11 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: { 19 20 inherit version; 21 22 name = "php-${version}"; 23 24 enableParallelBuilding = true; 25 26 nativeBuildInputs = [ pkgconfig ]; 27 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 "--with-mysql-sock=/run/mysqld/mysqld.sock"]; 120 buildInputs = mysqlBuildInputs; 121 }; 122 123 mysqli = { 124 configureFlags = ["--with-mysqli=${if mysqlndSupport then "mysqlnd" else "${mysql.connector-c}/bin/mysql_config"}" 125 "--with-mysql-sock=/run/mysqld/mysqld.sock"]; 126 buildInputs = mysqlBuildInputs; 127 }; 128 129 mysqli_embedded = { 130 configureFlags = ["--enable-embedded-mysqli"]; 131 depends = "mysqli"; 132 assertion = fixed.mysqliSupport; 133 }; 134 135 pdo_mysql = { 136 configureFlags = ["--with-pdo-mysql=${if mysqlndSupport then "mysqlnd" else mysql.connector-c}" 137 "--with-mysql-sock=/run/mysqld/mysqld.sock"]; 138 buildInputs = mysqlBuildInputs; 139 }; 140 141 bcmath = { 142 configureFlags = ["--enable-bcmath"]; 143 }; 144 145 gd = { 146 # FIXME: Our own gd package doesn't work, see https://bugs.php.net/bug.php?id=60108. 147 configureFlags = [ 148 "--with-gd" 149 "--with-freetype-dir=${freetype.dev}" 150 "--with-png-dir=${libpng.dev}" 151 "--with-jpeg-dir=${libjpeg.dev}" 152 ]; 153 buildInputs = [ libpng libjpeg freetype ]; 154 }; 155 156 gmp = { 157 configureFlags = ["--with-gmp=${gmp.dev}"]; 158 buildInputs = [ gmp ]; 159 }; 160 161 soap = { 162 configureFlags = ["--enable-soap"]; 163 }; 164 165 sockets = { 166 configureFlags = ["--enable-sockets"]; 167 }; 168 169 openssl = { 170 configureFlags = ["--with-openssl"]; 171 buildInputs = [openssl openssl.dev]; 172 }; 173 174 mbstring = { 175 configureFlags = ["--enable-mbstring"]; 176 }; 177 178 gettext = { 179 configureFlags = ["--with-gettext=${gettext}"]; 180 buildInputs = [gettext]; 181 }; 182 183 intl = { 184 configureFlags = ["--enable-intl"]; 185 buildInputs = [icu]; 186 }; 187 188 exif = { 189 configureFlags = ["--enable-exif"]; 190 }; 191 192 xsl = { 193 configureFlags = ["--with-xsl=${libxslt.dev}"]; 194 buildInputs = [libxslt]; 195 }; 196 197 mcrypt = let libmcrypt' = libmcrypt.override { disablePosixThreads = true; }; in { 198 configureFlags = ["--with-mcrypt=${libmcrypt'}"]; 199 buildInputs = [libmcrypt']; 200 }; 201 202 bz2 = { 203 configureFlags = ["--with-bz2=${bzip2.dev}"]; 204 buildInputs = [bzip2]; 205 }; 206 207 zip = { 208 configureFlags = ["--enable-zip"]; 209 }; 210 211 ftp = { 212 configureFlags = ["--enable-ftp"]; 213 }; 214 215 fpm = { 216 configureFlags = ["--enable-fpm"]; 217 }; 218 219 mssql = stdenv.lib.optionalAttrs (!stdenv.isDarwin) { 220 configureFlags = ["--with-mssql=${freetds}"]; 221 buildInputs = [freetds]; 222 }; 223 224 zts = { 225 configureFlags = ["--enable-maintainer-zts"]; 226 }; 227 228 calendar = { 229 configureFlags = ["--enable-calendar"]; 230 }; 231 232 sodium = { 233 configureFlags = ["--with-sodium=${libsodium.dev}"]; 234 buildInputs = [libsodium]; 235 }; 236 }; 237 238 cfg = { 239 imapSupport = config.php.imap or (!stdenv.isDarwin); 240 ldapSupport = config.php.ldap or true; 241 mhashSupport = config.php.mhash or true; 242 mysqlSupport = (!php7) && (config.php.mysql or true); 243 mysqliSupport = config.php.mysqli or true; 244 pdo_mysqlSupport = config.php.pdo_mysql or true; 245 libxml2Support = config.php.libxml2 or true; 246 apxs2Support = config.php.apxs2 or (!stdenv.isDarwin); 247 embedSupport = config.php.embed or false; 248 bcmathSupport = config.php.bcmath or true; 249 socketsSupport = config.php.sockets or true; 250 curlSupport = config.php.curl or true; 251 curlWrappersSupport = (!php7) && (config.php.curlWrappers or true); 252 gettextSupport = config.php.gettext or true; 253 pcntlSupport = config.php.pcntl or true; 254 postgresqlSupport = config.php.postgresql or true; 255 pdo_pgsqlSupport = config.php.pdo_pgsql or true; 256 readlineSupport = config.php.readline or true; 257 sqliteSupport = config.php.sqlite or true; 258 soapSupport = config.php.soap or true; 259 zlibSupport = config.php.zlib or true; 260 opensslSupport = config.php.openssl or true; 261 mbstringSupport = config.php.mbstring or true; 262 gdSupport = config.php.gd or true; 263 intlSupport = config.php.intl or true; 264 exifSupport = config.php.exif or true; 265 xslSupport = config.php.xsl or false; 266 mcryptSupport = config.php.mcrypt or true; 267 bz2Support = config.php.bz2 or false; 268 zipSupport = config.php.zip or true; 269 ftpSupport = config.php.ftp or true; 270 fpmSupport = config.php.fpm or true; 271 gmpSupport = config.php.gmp or true; 272 mssqlSupport = (!php7) && (config.php.mssql or (!stdenv.isDarwin)); 273 ztsSupport = config.php.zts or false; 274 calendarSupport = config.php.calendar or true; 275 sodiumSupport = (lib.versionAtLeast version "7.2") && config.php.sodium or true; 276 }; 277 278 hardeningDisable = [ "bindnow" ]; 279 280 preConfigure = '' 281 # Don't record the configure flags since this causes unnecessary 282 # runtime dependencies 283 for i in main/build-defs.h.in scripts/php-config.in; do 284 substituteInPlace $i \ 285 --replace '@CONFIGURE_COMMAND@' '(omitted)' \ 286 --replace '@CONFIGURE_OPTIONS@' "" \ 287 --replace '@PHP_LDFLAGS@' "" 288 done 289 290 #[[ -z "$libxml2" ]] || addToSearchPath PATH $libxml2/bin 291 292 export EXTENSION_DIR=$out/lib/php/extensions 293 294 configureFlags+=(--with-config-file-path=$out/etc \ 295 --includedir=$dev/include) 296 ''; 297 298 configureFlags = [ 299 "--with-config-file-scan-dir=/etc/php.d" 300 "--with-pcre-regex=${pcre.dev} PCRE_LIBDIR=${pcre}" 301 ] ++ lib.optional stdenv.isDarwin "--with-iconv=${libiconv}" 302 ++ lib.optional stdenv.isLinux "--with-fpm-systemd"; 303 304 postInstall = '' 305 cp php.ini-production $out/etc/php.ini 306 ''; 307 308 postFixup = '' 309 mkdir -p $dev/bin $dev/share/man/man1 310 mv $out/bin/phpize $out/bin/php-config $dev/bin/ 311 mv $out/share/man/man1/phpize.1.gz \ 312 $out/share/man/man1/php-config.1.gz \ 313 $dev/share/man/man1/ 314 ''; 315 316 src = fetchurl { 317 url = "http://www.php.net/distributions/php-${version}.tar.bz2"; 318 inherit sha256; 319 }; 320 321 meta = with stdenv.lib; { 322 description = "An HTML-embedded scripting language"; 323 homepage = http://www.php.net/; 324 license = licenses.php301; 325 maintainers = with maintainers; [ globin etu ]; 326 platforms = platforms.all; 327 outputsToInstall = [ "out" "dev" ]; 328 }; 329 330 patches = if !php7 then [ ./fix-paths.patch ] else [ ./fix-paths-php7.patch ]; 331 332 postPatch = lib.optional stdenv.isDarwin '' 333 substituteInPlace configure --replace "-lstdc++" "-lc++" 334 ''; 335 336 stripDebugList = "bin sbin lib modules"; 337 338 outputs = [ "out" "dev" ]; 339 340 }); 341 342in { 343 php56 = generic { 344 version = "5.6.38"; 345 sha256 = "00xw7rcq36dlrzgx9nr96jc64gnnrxjxkkpmkr1y8fynpldj6nyn"; 346 }; 347 348 php70 = generic { 349 version = "7.0.32"; 350 sha256 = "1qcjch3293h3fwci767x9rih3nrvz02rhn33hvx8l5q8kk7xis2n"; 351 }; 352 353 php71 = generic { 354 version = "7.1.21"; 355 sha256 = "104mn4kppklb21hgz1a50kgmc0ak5y996sx990xpc8yy9dbrqh62"; 356 }; 357 358 php72 = generic { 359 version = "7.2.8"; 360 sha256 = "1rky321gcvjm0npbfd4bznh36an0y14viqcvn4yzy3x643sni00z"; 361 }; 362}