at 18.09-beta 231 lines 9.0 kB view raw
1# pcre functionality is tested in nixos/tests/php-pcre.nix 2{ lib, stdenv, fetchurl, flex, bison 3, mysql, libxml2, readline, zlib, curl, postgresql, gettext 4, openssl, pcre, pkgconfig, sqlite, config, libjpeg, libpng, freetype 5, libxslt, libmcrypt, bzip2, icu, openldap, cyrus_sasl, libmhash, freetds 6, uwimap, pam, gmp, apacheHttpd, libiconv, systemd, libsodium, html-tidy 7}: 8 9with lib; 10 11let 12 generic = 13 { version 14 , sha256 15 , imapSupport ? config.php.imap or (!stdenv.isDarwin) 16 , ldapSupport ? config.php.ldap or true 17 , mhashSupport ? config.php.mhash or true 18 , mysqlSupport ? (config.php.mysql or true) 19 , mysqlndSupport ? config.php.mysqlnd or true 20 , mysqliSupport ? config.php.mysqli or true 21 , pdo_mysqlSupport ? config.php.pdo_mysql or true 22 , libxml2Support ? config.php.libxml2 or true 23 , apxs2Support ? config.php.apxs2 or (!stdenv.isDarwin) 24 , embedSupport ? config.php.embed or false 25 , bcmathSupport ? config.php.bcmath or true 26 , socketsSupport ? config.php.sockets or true 27 , curlSupport ? config.php.curl or true 28 , curlWrappersSupport ? config.php.curlWrappers or true 29 , gettextSupport ? config.php.gettext or true 30 , pcntlSupport ? config.php.pcntl or true 31 , postgresqlSupport ? config.php.postgresql or true 32 , pdo_pgsqlSupport ? config.php.pdo_pgsql or true 33 , readlineSupport ? config.php.readline or true 34 , sqliteSupport ? config.php.sqlite or true 35 , soapSupport ? config.php.soap or true 36 , zlibSupport ? config.php.zlib or true 37 , opensslSupport ? config.php.openssl or true 38 , mbstringSupport ? config.php.mbstring or true 39 , gdSupport ? config.php.gd or true 40 , intlSupport ? config.php.intl or true 41 , exifSupport ? config.php.exif or true 42 , xslSupport ? config.php.xsl or false 43 , mcryptSupport ? config.php.mcrypt or true 44 , bz2Support ? config.php.bz2 or false 45 , zipSupport ? config.php.zip or true 46 , ftpSupport ? config.php.ftp or true 47 , fpmSupport ? config.php.fpm or true 48 , gmpSupport ? config.php.gmp or true 49 , mssqlSupport ? config.php.mssql or (!stdenv.isDarwin) 50 , ztsSupport ? config.php.zts or false 51 , calendarSupport ? config.php.calendar or true 52 , sodiumSupport ? (config.php.sodium or true) && (versionAtLeast version "7.2") 53 , tidySupport ? (config.php.tidy or false) 54 }: 55 56 let 57 mysqlBuildInputs = optional (!mysqlndSupport) mysql.connector-c; 58 libmcrypt' = libmcrypt.override { disablePosixThreads = true; }; 59 in stdenv.mkDerivation { 60 61 inherit version; 62 63 name = "php-${version}"; 64 65 enableParallelBuilding = true; 66 67 nativeBuildInputs = [ pkgconfig ]; 68 buildInputs = [ flex bison pcre ] 69 ++ optional stdenv.isLinux systemd 70 ++ optionals imapSupport [ uwimap openssl pam ] 71 ++ optionals curlSupport [ curl openssl ] 72 ++ optionals ldapSupport [ openldap openssl ] 73 ++ optionals gdSupport [ libpng libjpeg freetype ] 74 ++ optionals opensslSupport [ openssl openssl.dev ] 75 ++ optional apxs2Support apacheHttpd 76 ++ optional (ldapSupport && stdenv.isLinux) cyrus_sasl 77 ++ optional mhashSupport libmhash 78 ++ optional zlibSupport zlib 79 ++ optional libxml2Support libxml2 80 ++ optional readlineSupport readline 81 ++ optional sqliteSupport sqlite 82 ++ optional postgresqlSupport postgresql 83 ++ optional pdo_pgsqlSupport postgresql 84 ++ optional pdo_mysqlSupport mysqlBuildInputs 85 ++ optional mysqlSupport mysqlBuildInputs 86 ++ optional mysqliSupport mysqlBuildInputs 87 ++ optional gmpSupport gmp 88 ++ optional gettextSupport gettext 89 ++ optional intlSupport icu 90 ++ optional xslSupport libxslt 91 ++ optional mcryptSupport libmcrypt' 92 ++ optional bz2Support bzip2 93 ++ optional (mssqlSupport && !stdenv.isDarwin) freetds 94 ++ optional sodiumSupport libsodium 95 ++ optional tidySupport html-tidy; 96 97 CXXFLAGS = optional stdenv.cc.isClang "-std=c++11"; 98 99 100 configureFlags = [ 101 "--with-config-file-scan-dir=/etc/php.d" 102 "--with-pcre-regex=${pcre.dev} PCRE_LIBDIR=${pcre}" 103 ] 104 ++ optional stdenv.isDarwin "--with-iconv=${libiconv}" 105 ++ optional stdenv.isLinux "--with-fpm-systemd" 106 ++ optionals imapSupport [ 107 "--with-imap=${uwimap}" 108 "--with-imap-ssl" 109 ] 110 ++ optionals ldapSupport [ 111 "--with-ldap=/invalid/path" 112 "LDAP_DIR=${openldap.dev}" 113 "LDAP_INCDIR=${openldap.dev}/include" 114 "LDAP_LIBDIR=${openldap.out}/lib" 115 ] 116 ++ optional (ldapSupport && stdenv.isLinux) "--with-ldap-sasl=${cyrus_sasl.dev}" 117 ++ optional apxs2Support "--with-apxs2=${apacheHttpd.dev}/bin/apxs" 118 ++ optional embedSupport "--enable-embed" 119 ++ optional mhashSupport "--with-mhash" 120 ++ optional curlSupport "--with-curl=${curl.dev}" 121 ++ optional curlWrappersSupport "--with-curlwrappers" 122 ++ optional zlibSupport "--with-zlib=${zlib.dev}" 123 ++ optional libxml2Support "--with-libxml-dir=${libxml2.dev}" 124 ++ optional pcntlSupport "--enable-pcntl" 125 ++ optional readlineSupport "--with-readline=${readline.dev}" 126 ++ optional sqliteSupport "--with-pdo-sqlite=${sqlite.dev}" 127 ++ optional postgresqlSupport "--with-pgsql=${postgresql}" 128 ++ optional pdo_pgsqlSupport "--with-pdo-pgsql=${postgresql}" 129 ++ optional pdo_mysqlSupport "--with-pdo-mysql=${if mysqlndSupport then "mysqlnd" else mysql.connector-c}" 130 ++ optional mysqlSupport "--with-mysql${if mysqlndSupport then "=mysqlnd" else ""}" 131 ++ optionals mysqliSupport [ 132 "--with-mysqli=${if mysqlndSupport then "mysqlnd" else "${mysql.connector-c}/bin/mysql_config"}" 133 ] 134 ++ optional bcmathSupport "--enable-bcmath" 135 # FIXME: Our own gd package doesn't work, see https://bugs.php.net/bug.php?id=60108. 136 ++ optionals gdSupport [ 137 "--with-gd" 138 "--with-freetype-dir=${freetype.dev}" 139 "--with-png-dir=${libpng.dev}" 140 "--with-jpeg-dir=${libjpeg.dev}" 141 ] 142 ++ optional gmpSupport "--with-gmp=${gmp.dev}" 143 ++ optional soapSupport "--enable-soap" 144 ++ optional socketsSupport "--enable-sockets" 145 ++ optional opensslSupport "--with-openssl" 146 ++ optional mbstringSupport "--enable-mbstring" 147 ++ optional gettextSupport "--with-gettext=${gettext}" 148 ++ optional intlSupport "--enable-intl" 149 ++ optional exifSupport "--enable-exif" 150 ++ optional xslSupport "--with-xsl=${libxslt.dev}" 151 ++ optional mcryptSupport "--with-mcrypt=${libmcrypt'}" 152 ++ optional bz2Support "--with-bz2=${bzip2.dev}" 153 ++ optional zipSupport "--enable-zip" 154 ++ optional ftpSupport "--enable-ftp" 155 ++ optional fpmSupport "--enable-fpm" 156 ++ optional (mssqlSupport && !stdenv.isDarwin) "--with-mssql=${freetds}" 157 ++ optional ztsSupport "--enable-maintainer-zts" 158 ++ optional calendarSupport "--enable-calendar" 159 ++ optional sodiumSupport "--with-sodium=${libsodium.dev}" 160 ++ optional tidySupport "--with-tidy=${html-tidy}"; 161 162 163 hardeningDisable = [ "bindnow" ]; 164 165 preConfigure = '' 166 # Don't record the configure flags since this causes unnecessary 167 # runtime dependencies 168 for i in main/build-defs.h.in scripts/php-config.in; do 169 substituteInPlace $i \ 170 --replace '@CONFIGURE_COMMAND@' '(omitted)' \ 171 --replace '@CONFIGURE_OPTIONS@' "" \ 172 --replace '@PHP_LDFLAGS@' "" 173 done 174 175 #[[ -z "$libxml2" ]] || addToSearchPath PATH $libxml2/bin 176 177 export EXTENSION_DIR=$out/lib/php/extensions 178 179 configureFlags+=(--with-config-file-path=$out/etc \ 180 --includedir=$dev/include) 181 ''; 182 183 postInstall = '' 184 cp php.ini-production $out/etc/php.ini 185 ''; 186 187 postFixup = '' 188 mkdir -p $dev/bin $dev/share/man/man1 189 mv $out/bin/phpize $out/bin/php-config $dev/bin/ 190 mv $out/share/man/man1/phpize.1.gz \ 191 $out/share/man/man1/php-config.1.gz \ 192 $dev/share/man/man1/ 193 ''; 194 195 src = fetchurl { 196 url = "http://www.php.net/distributions/php-${version}.tar.bz2"; 197 inherit sha256; 198 }; 199 200 meta = with stdenv.lib; { 201 description = "An HTML-embedded scripting language"; 202 homepage = http://www.php.net/; 203 license = licenses.php301; 204 maintainers = with maintainers; [ globin etu ]; 205 platforms = platforms.all; 206 outputsToInstall = [ "out" "dev" ]; 207 }; 208 209 patches = [ ./fix-paths-php7.patch ]; 210 211 postPatch = optional stdenv.isDarwin '' 212 substituteInPlace configure --replace "-lstdc++" "-lc++" 213 ''; 214 215 stripDebugList = "bin sbin lib modules"; 216 217 outputs = [ "out" "dev" ]; 218 219 }; 220 221in { 222 php71 = generic { 223 version = "7.1.21"; 224 sha256 = "104mn4kppklb21hgz1a50kgmc0ak5y996sx990xpc8yy9dbrqh62"; 225 }; 226 227 php72 = generic { 228 version = "7.2.8"; 229 sha256 = "1rky321gcvjm0npbfd4bznh36an0y14viqcvn4yzy3x643sni00z"; 230 }; 231}