50 lib.makeScope pkgs.newScope (self: with self; {
51 buildPecl = import ../build-support/build-pecl.nix {
54 inherit (pkgs) stdenv autoreconfHook fetchurl re2c;
57 # Wrap mkDerivation to prepend pname with "php-" to make names consistent
58 # with how buildPecl does it and make the file easier to overview.
59 mkDerivation = { pname, ... }@args: pkgs.stdenv.mkDerivation (args // {
60 pname = "php-${pname}";
61 meta.mainProgram = args.meta.mainProgram or pname;
64 # Function to build an extension which is shipped as part of the php
65 # source, based on the php version.
67 # Name passed is the name of the extension and is automatically used
68 # to add the configureFlag "--enable-${name}", which can be overriden.
70 # Build inputs is used for extra deps that may be needed. And zendExtension
71 # will mark the extension as a zend extension or not.
72 mkExtension = lib.makeOverridable
74 , configureFlags ? [ "--enable-${name}" ]
78 , zendExtension ? false
81 }@args: stdenv.mkDerivation ((builtins.removeAttrs args [ "name" ]) // {
82 pname = "php-${name}";
85 outputs = [ "out" "dev" ];
87 inherit (php.unwrapped) version src;
89 enableParallelBuilding = true;
98 inherit configureFlags internalDeps buildInputs zendExtension doCheck;
100 preConfigurePhases = [
101 "cdToExtensionRootPhase"
104 cdToExtensionRootPhase = ''
105 # Go to extension source root.
110 nullglobRestore=$(shopt -p nullglob)
111 shopt -u nullglob # To make ?-globbing work
113 # Some extensions have a config0.m4 or config9.m4
114 if [ -f config?.m4 ]; then
115 mv config?.m4 config.m4
123 ${lib.concatMapStringsSep
125 (dep: "mkdir -p ext; ln -s ${dep.dev}/include ext/${dep.extensionName}")
133 NO_INTERACTON=yes SKIP_PERF_SENSITIVE=yes make test
141 mkdir -p $out/lib/php/extensions
142 cp modules/${name}.so $out/lib/php/extensions/${name}.so
143 mkdir -p $dev/include
144 ${rsync}/bin/rsync -r --filter="+ */" \
154 description = "PHP upstream extension: ${name}";
155 inherit (php.meta) maintainers homepage license;
161 # This is a set of interactive tools based on PHP.
163 box = callPackage ../development/php-packages/box { };
165 composer = callPackage ../development/php-packages/composer { };
167 deployer = callPackage ../development/php-packages/deployer { };
169 grumphp = callPackage ../development/php-packages/grumphp { };
171 phing = callPackage ../development/php-packages/phing { };
173 phive = callPackage ../development/php-packages/phive { };
175 php-cs-fixer = callPackage ../development/php-packages/php-cs-fixer { };
177 php-parallel-lint = callPackage ../development/php-packages/php-parallel-lint { };
179 phpcbf = callPackage ../development/php-packages/phpcbf { };
181 phpcs = callPackage ../development/php-packages/phpcs { };
183 phpmd = callPackage ../development/php-packages/phpmd { };
185 phpstan = callPackage ../development/php-packages/phpstan { };
187 psalm = callPackage ../development/php-packages/psalm { };
189 psysh = callPackage ../development/php-packages/psysh { };
194 # This is a set of PHP extensions meant to be used in php.buildEnv
195 # or php.withExtensions to extend the functionality of the PHP
198 amqp = callPackage ../development/php-packages/amqp { };
200 apcu = callPackage ../development/php-packages/apcu { };
202 ast = callPackage ../development/php-packages/ast { };
204 blackfire = pkgs.callPackage ../development/tools/misc/blackfire/php-probe.nix { inherit php; };
206 couchbase = callPackage ../development/php-packages/couchbase { };
208 datadog_trace = callPackage ../development/php-packages/datadog_trace { };
210 ds = callPackage ../development/php-packages/ds { };
212 event = callPackage ../development/php-packages/event { };
214 gnupg = callPackage ../development/php-packages/gnupg { };
216 grpc = callPackage ../development/php-packages/grpc { };
218 igbinary = callPackage ../development/php-packages/igbinary { };
220 imagick = callPackage ../development/php-packages/imagick { };
222 inotify = callPackage ../development/php-packages/inotify { };
224 mailparse = callPackage ../development/php-packages/mailparse { };
226 maxminddb = callPackage ../development/php-packages/maxminddb { };
228 memcached = callPackage ../development/php-packages/memcached { };
230 mongodb = callPackage ../development/php-packages/mongodb { };
232 oci8 = callPackage ../development/php-packages/oci8 { };
234 openswoole = callPackage ../development/php-packages/openswoole { };
236 pdlib = callPackage ../development/php-packages/pdlib { };
238 pcov = callPackage ../development/php-packages/pcov { };
240 pdo_oci = buildPecl rec {
241 inherit (php.unwrapped) src version;
244 sourceRoot = "php-${version}/ext/pdo_oci";
246 buildInputs = [ pkgs.oracle-instantclient ];
247 configureFlags = [ "--with-pdo-oci=instantclient,${pkgs.oracle-instantclient.lib}/lib" ];
249 internalDeps = [ php.extensions.pdo ];
252 sed -i -e 's|OCISDKMANINC=`.*$|OCISDKMANINC="${pkgs.oracle-instantclient.dev}/include"|' config.m4
255 meta.maintainers = lib.teams.php.members;
258 pdo_sqlsrv = callPackage ../development/php-packages/pdo_sqlsrv { };
260 pinba = callPackage ../development/php-packages/pinba { };
262 protobuf = callPackage ../development/php-packages/protobuf { };
264 rdkafka = callPackage ../development/php-packages/rdkafka { };
266 redis = callPackage ../development/php-packages/redis { };
268 smbclient = callPackage ../development/php-packages/smbclient { };
270 snuffleupagus = callPackage ../development/php-packages/snuffleupagus { };
272 sqlsrv = callPackage ../development/php-packages/sqlsrv { };
274 swoole = callPackage ../development/php-packages/swoole { };
276 xdebug = callPackage ../development/php-packages/xdebug { };
278 yaml = callPackage ../development/php-packages/yaml { };
281 # This list contains build instructions for different modules that one may
284 # These will be passed as arguments to mkExtension above.
287 { name = "bz2"; buildInputs = [ bzip2 ]; configureFlags = [ "--with-bz2=${bzip2.dev}" ]; }
288 { name = "calendar"; }
292 buildInputs = [ curl ];
293 configureFlags = [ "--with-curl=${curl.dev}" ];
299 buildInputs = [ libxml2 ];
306 buildInputs = [ enchant1 ];
307 configureFlags = [ "--with-enchant=${enchant1}" ];
308 # enchant1 doesn't build on darwin.
309 enable = (!stdenv.isDarwin);
312 { name = "exif"; doCheck = false; }
313 { name = "ffi"; buildInputs = [ libffi ]; }
314 { name = "fileinfo"; buildInputs = [ pcre2 ]; }
315 { name = "filter"; buildInputs = [ pcre2 ]; }
316 { name = "ftp"; buildInputs = [ openssl ]; }
319 buildInputs = [ zlib gd ];
322 "--with-external-gd=${gd.dev}"
323 "--enable-gd-jis-conv"
329 buildInputs = [ gettext ];
330 postPhpize = ''substituteInPlace configure --replace 'as_fn_error $? "Cannot locate header file libintl.h" "$LINENO" 5' ':' '';
331 configureFlags = [ "--with-gettext=${gettext}" ];
335 buildInputs = [ gmp ];
336 configureFlags = [ "--with-gmp=${gmp.dev}" ];
341 "--with-iconv${lib.optionalString stdenv.isDarwin "=${libiconv}"}"
347 buildInputs = [ uwimap openssl pam pcre2 libkrb5 ];
348 configureFlags = [ "--with-imap=${uwimap}" "--with-imap-ssl" "--with-kerberos" ];
352 buildInputs = [ icu64 ];
356 buildInputs = [ openldap cyrus_sasl ];
359 "LDAP_DIR=${openldap.dev}"
360 "LDAP_INCDIR=${openldap.dev}/include"
361 "LDAP_LIBDIR=${openldap.out}/lib"
362 ] ++ lib.optionals stdenv.isLinux [
363 "--with-ldap-sasl=${cyrus_sasl.dev}"
369 buildInputs = [ oniguruma pcre2 ];
374 internalDeps = [ php.extensions.mysqlnd ];
375 configureFlags = [ "--with-mysqli=mysqlnd" "--with-mysql-sock=/run/mysqld/mysqld.sock" ];
380 buildInputs = [ zlib openssl ];
381 # The configure script doesn't correctly add library link
382 # flags, so we add them to the variable used by the Makefile
384 MYSQLND_SHARED_LIBADD = "-lssl -lcrypto";
385 # The configure script builds a config.h which is never
386 # included. Let's include it in the main header file
387 # included by all .c-files.
389 (pkgs.writeText "mysqlnd_config.patch" ''
390 --- a/ext/mysqlnd/mysqlnd.h
391 +++ b/ext/mysqlnd/mysqlnd.h
393 +#ifdef HAVE_CONFIG_H
397 +----------------------------------------------------------------------+
398 | Copyright (c) The PHP Group |
404 buildInputs = [ pcre2 ] ++ lib.optionals (!stdenv.isDarwin) [
407 zendExtension = true;
408 # Tests launch the builtin webserver.
409 __darwinAllowLocalNetworking = true;
413 buildInputs = if (lib.versionAtLeast php.version "8.1") then [ openssl ] else [ openssl_1_1 ];
414 configureFlags = [ "--with-openssl" ];
418 { name = "pdo"; doCheck = false; }
421 internalDeps = [ php.extensions.pdo ];
422 configureFlags = [ "--with-pdo-dblib=${freetds}" ];
423 # Doesn't seem to work on darwin.
424 enable = (!stdenv.isDarwin);
429 internalDeps = with php.extensions; [ pdo mysqlnd ];
430 configureFlags = [ "--with-pdo-mysql=mysqlnd" "PHP_MYSQL_SOCK=/run/mysqld/mysqld.sock" ];
435 internalDeps = [ php.extensions.pdo ];
436 configureFlags = [ "--with-pdo-odbc=unixODBC,${unixODBC}" ];
441 internalDeps = [ php.extensions.pdo ];
442 configureFlags = [ "--with-pdo-pgsql=${postgresql}" ];
447 internalDeps = [ php.extensions.pdo ];
448 buildInputs = [ sqlite ];
449 configureFlags = [ "--with-pdo-sqlite=${sqlite.dev}" ];
454 buildInputs = [ pcre2 ];
455 configureFlags = [ "--with-pgsql=${postgresql}" ];
458 { name = "posix"; doCheck = false; }
459 { name = "pspell"; configureFlags = [ "--with-pspell=${aspell}" ]; }
466 "--with-readline=${readline.dev}"
469 # Fix `--with-readline` option not being available.
470 # `PHP_ALWAYS_SHARED` generated by phpize enables all options
471 # without the possibility to override them. But when `--with-libedit`
472 # is enabled, `--with-readline` is not registered.
474 AC_DEFUN([PHP_ALWAYS_SHARED],[
475 test "[$]$1" != "no" && ext_shared=yes
477 ' | cat - ext/readline/config.m4 > ext/readline/config.m4.tmp
478 mv ext/readline/config.m4{.tmp,}
482 { name = "session"; doCheck = false; }
486 buildInputs = [ libxml2 pcre2 ];
493 buildInputs = [ net-snmp openssl ];
494 configureFlags = [ "--with-snmp" ];
495 # net-snmp doesn't build on darwin.
496 enable = (!stdenv.isDarwin);
501 buildInputs = [ libxml2 ];
511 { name = "sodium"; buildInputs = [ libsodium ]; }
512 { name = "sqlite3"; buildInputs = [ sqlite ]; }
513 { name = "sysvmsg"; }
514 { name = "sysvsem"; }
515 { name = "sysvshm"; }
516 { name = "tidy"; configureFlags = [ "--with-tidy=${html-tidy}" ]; doCheck = false; }
519 patches = lib.optional (lib.versionAtLeast php.version "8.1")
520 ../development/interpreters/php/fix-tokenizer-php81.patch;
524 buildInputs = [ libxml2 ];
532 buildInputs = [ libxml2 ];
533 internalDeps = [ php.extensions.dom ];
534 NIX_CFLAGS_COMPILE = [ "-I../.." "-DHAVE_DOM" ];
542 buildInputs = [ libxml2 ];
549 buildInputs = [ libxslt libxml2 ];
551 configureFlags = [ "--with-xsl=${libxslt.dev}" ];
553 { name = "zend_test"; }
556 buildInputs = [ libzip pcre2 ];
564 buildInputs = [ zlib ];
571 # Convert the list of attrs:
572 # [ { name = <name>; ... } ... ]
574 # [ { name = <name>; value = <extension drv>; } ... ]
576 # which we later use listToAttrs to make all attrs available by name.
578 # Also filter out extensions based on the enable property.
579 namedExtensions = builtins.map
582 value = mkExtension drv;
584 (builtins.filter (i: i.enable or true) extensionData);
586 # Produce the final attribute set of all extensions defined.
588 builtins.listToAttrs namedExtensions