vuls: init at 0.27.0 (#348530)
[NixPkgs.git] / pkgs / top-level / php-packages.nix
blob0e4fc0b6ecaefbab6d01d28ce1905da675b75a45
1 { stdenv
2 , config
3 , callPackages
4 , lib
5 , pkgs
6 , phpPackage
7 , autoconf
8 , pkg-config
9 , bzip2
10 , curl
11 , cyrus_sasl
12 , enchant2
13 , freetds
14 , gd
15 , gettext
16 , gmp
17 , html-tidy
18 , icu73
19 , libffi
20 , libiconv
21 , libkrb5
22 , libsodium
23 , libxml2
24 , libxslt
25 , libzip
26 , net-snmp
27 , nix-update-script
28 , oniguruma
29 , openldap
30 , openssl_1_1
31 , openssl
32 , overrideSDK
33 , pam
34 , pcre2
35 , postgresql
36 , bison
37 , re2c
38 , readline
39 , rsync
40 , sqlite
41 , unixODBC
42 , uwimap
43 , valgrind
44 , zlib
45 , fetchpatch
48 lib.makeScope pkgs.newScope (self: let
49   inherit (self) buildPecl callPackage mkExtension php;
51   builders = import ../build-support/php/builders {
52     inherit callPackages callPackage buildPecl;
53   };
54 in {
55   buildPecl = callPackage ../build-support/php/build-pecl.nix {
56     php = php.unwrapped;
57   };
59   inherit (builders.v1) buildComposerProject buildComposerWithPlugin composerHooks mkComposerRepository;
61   # Next version of the builder
62   buildComposerProject2 = builders.v2.buildComposerProject;
63   composerHooks2 = builders.v2.composerHooks;
64   mkComposerVendor = builders.v2.mkComposerVendor;
66   # Wrap mkDerivation to prepend pname with "php-" to make names consistent
67   # with how buildPecl does it and make the file easier to overview.
68   mkDerivation = origArgs:
69     let
70       args = lib.fix (lib.extends
71         (_: previousAttrs: {
72           pname = "php-${previousAttrs.pname}";
73           passthru = (previousAttrs.passthru or { }) // {
74             updateScript = nix-update-script { };
75           };
76           meta = (previousAttrs.meta or { }) // {
77             mainProgram = previousAttrs.meta.mainProgram or previousAttrs.pname;
78           };
79         })
80         (if lib.isFunction origArgs then origArgs else (_: origArgs))
81       );
82     in
83     pkgs.stdenv.mkDerivation args;
85   # Function to build an extension which is shipped as part of the php
86   # source, based on the php version.
87   #
88   # Name passed is the name of the extension and is automatically used
89   # to add the configureFlag "--enable-${name}", which can be overridden.
90   #
91   # Build inputs is used for extra deps that may be needed. And zendExtension
92   # will mark the extension as a zend extension or not.
93   mkExtension = lib.makeOverridable
94     ({ name
95      , configureFlags ? [ "--enable-${extName}" ]
96      , internalDeps ? [ ]
97      , postPhpize ? ""
98      , buildInputs ? [ ]
99      , zendExtension ? false
100      , doCheck ? true
101      , extName ? name
102      , ...
103      }@args: stdenv.mkDerivation ((builtins.removeAttrs args [ "name" ]) // {
104       pname = "php-${name}";
105       extensionName = extName;
107       outputs = [ "out" "dev" ];
109       inherit (php.unwrapped) version src;
111       enableParallelBuilding = true;
113       nativeBuildInputs = [
114         php.unwrapped
115         autoconf
116         pkg-config
117         re2c
118         bison
119       ];
121       inherit configureFlags internalDeps buildInputs zendExtension doCheck;
123       preConfigurePhases = [
124         "genfiles"
125         "cdToExtensionRootPhase"
126       ];
128       genfiles = ''
129         if [ -f "scripts/dev/genfiles" ]; then
130           ./scripts/dev/genfiles
131         fi
132       '';
134       cdToExtensionRootPhase = ''
135         # Go to extension source root.
136         cd "ext/${extName}"
137       '';
139       preConfigure = ''
140         nullglobRestore=$(shopt -p nullglob)
141         shopt -u nullglob   # To make ?-globbing work
143         # Some extensions have a config0.m4 or config9.m4
144         if [ -f config?.m4 ]; then
145           mv config?.m4 config.m4
146         fi
148         $nullglobRestore
150         phpize
151         ${postPhpize}
153         ${lib.concatMapStringsSep
154           "\n"
155           (dep: "mkdir -p ext; ln -s ${dep.dev}/include ext/${dep.extensionName}")
156           internalDeps
157         }
158       '';
160       checkPhase = ''
161         runHook preCheck
163         NO_INTERACTION=yes SKIP_PERF_SENSITIVE=yes SKIP_ONLINE_TESTS=yes make test
164         runHook postCheck
165       '';
167       installPhase = ''
168         runHook preInstall
170         mkdir -p $out/lib/php/extensions
171         cp modules/${extName}.so $out/lib/php/extensions/${extName}.so
172         mkdir -p $dev/include
173         ${rsync}/bin/rsync -r --filter="+ */" \
174                               --filter="+ *.h" \
175                               --filter="- *" \
176                               --prune-empty-dirs \
177                               . $dev/include/
179         runHook postInstall
180       '';
182       meta = {
183         description = "PHP upstream extension: ${name}";
184         inherit (php.meta) maintainers homepage license;
185       };
186     }));
188   php = phpPackage;
190   # This is a set of interactive tools based on PHP.
191   tools = {
192     box = callPackage ../development/php-packages/box { };
194     castor = callPackage ../development/php-packages/castor { };
196     composer = callPackage ../development/php-packages/composer { };
198     composer-local-repo-plugin = callPackage ../development/php-packages/composer-local-repo-plugin { };
200     cyclonedx-php-composer = callPackage ../development/php-packages/cyclonedx-php-composer { };
202     deployer = callPackage ../development/php-packages/deployer { };
204     grumphp = callPackage ../development/php-packages/grumphp { };
206     phan = callPackage ../development/php-packages/phan { };
208     phing = callPackage ../development/php-packages/phing { };
210     phive = callPackage ../development/php-packages/phive { };
212     php-codesniffer = callPackage ../development/php-packages/php-codesniffer { };
214     php-cs-fixer = callPackage ../development/php-packages/php-cs-fixer { };
216     php-parallel-lint = callPackage ../development/php-packages/php-parallel-lint { };
218     phpinsights = callPackage ../development/php-packages/phpinsights { };
220     phpmd = callPackage ../development/php-packages/phpmd { };
222     phpspy = callPackage ../development/php-packages/phpspy { };
224     phpstan = callPackage ../development/php-packages/phpstan { };
226     psalm = callPackage ../development/php-packages/psalm { };
228     psysh = callPackage ../development/php-packages/psysh { };
229   } // lib.optionalAttrs config.allowAliases {
230     phpcbf = throw "`phpcbf` is now deprecated, use `php-codesniffer` instead which contains both `phpcs` and `phpcbf`.";
231     phpcs = throw "`phpcs` is now deprecated, use `php-codesniffer` instead which contains both `phpcs` and `phpcbf`.";
232   };
234   # This is a set of PHP extensions meant to be used in php.buildEnv
235   # or php.withExtensions to extend the functionality of the PHP
236   # interpreter.
237   # The extensions attributes is composed of three sections:
238   # 1. The contrib conditional extensions, which are only available on specific PHP versions
239   # 2. The contrib extensions available
240   # 3. The core extensions
241   extensions =
242   # Contrib extensions
243   {
244     amqp = callPackage ../development/php-packages/amqp { };
246     apcu = callPackage ../development/php-packages/apcu { };
248     ast = callPackage ../development/php-packages/ast { };
250     blackfire = callPackage ../development/tools/misc/blackfire/php-probe.nix { };
252     couchbase = callPackage ../development/php-packages/couchbase { };
254     datadog_trace = callPackage ../development/php-packages/datadog_trace {
255       buildPecl = buildPecl.override {
256         stdenv = if stdenv.hostPlatform.isDarwin then overrideSDK stdenv "11.0" else stdenv;
257       };
258       inherit (pkgs) darwin;
259     };
261     ds = callPackage ../development/php-packages/ds { };
263     event = callPackage ../development/php-packages/event { };
265     gnupg = callPackage ../development/php-packages/gnupg { };
267     grpc = callPackage ../development/php-packages/grpc { };
269     igbinary = callPackage ../development/php-packages/igbinary { };
271     imagick = callPackage ../development/php-packages/imagick { };
273     # Shadowed by built-in version on PHP < 8.3.
274     imap = callPackage ../development/php-packages/imap { };
276     inotify = callPackage ../development/php-packages/inotify { };
278     ioncube-loader = callPackage ../development/php-packages/ioncube-loader { };
280     mailparse = callPackage ../development/php-packages/mailparse { };
282     maxminddb = callPackage ../development/php-packages/maxminddb { };
284     memcache = callPackage ../development/php-packages/memcache { };
286     memcached = callPackage ../development/php-packages/memcached { };
288     meminfo = callPackage ../development/php-packages/meminfo { };
290     memprof = callPackage ../development/php-packages/memprof { };
292     mongodb = callPackage ../development/php-packages/mongodb {
293       inherit (pkgs) darwin;
294     };
296     msgpack = callPackage ../development/php-packages/msgpack { };
298     oci8 = callPackage ../development/php-packages/oci8 { };
300     opentelemetry = callPackage ../development/php-packages/opentelemetry { };
302     openswoole = callPackage ../development/php-packages/openswoole { };
304     pdlib = callPackage ../development/php-packages/pdlib { };
306     pcov = callPackage ../development/php-packages/pcov { };
308     pdo_oci = buildPecl rec {
309       inherit (php.unwrapped) src version;
311       pname = "pdo_oci";
312       sourceRoot = "php-${version}/ext/pdo_oci";
314       buildInputs = [ pkgs.oracle-instantclient ];
315       configureFlags = [ "--with-pdo-oci=instantclient,${pkgs.oracle-instantclient.lib}/lib" ];
317       internalDeps = [ php.extensions.pdo ];
319       postPatch = ''
320         sed -i -e 's|OCISDKMANINC=`.*$|OCISDKMANINC="${pkgs.oracle-instantclient.dev}/include"|' config.m4
321       '';
323       meta.maintainers = lib.teams.php.members;
324     };
326     pdo_sqlsrv = callPackage ../development/php-packages/pdo_sqlsrv { };
328     phalcon = callPackage ../development/php-packages/phalcon { };
330     pinba = callPackage ../development/php-packages/pinba { };
332     protobuf = callPackage ../development/php-packages/protobuf { };
334     pspell = callPackage ../development/php-packages/pspell { };
336     rdkafka = callPackage ../development/php-packages/rdkafka { };
338     redis = callPackage ../development/php-packages/redis { };
340     relay = callPackage ../development/php-packages/relay { };
342     rrd = callPackage ../development/php-packages/rrd { };
344     smbclient = callPackage ../development/php-packages/smbclient { };
346     snuffleupagus = callPackage ../development/php-packages/snuffleupagus {
347       inherit (pkgs) darwin;
348     };
350     spx = callPackage ../development/php-packages/spx { };
352     sqlsrv = callPackage ../development/php-packages/sqlsrv { };
354     ssh2 = callPackage ../development/php-packages/ssh2 { };
356     swoole = callPackage ../development/php-packages/swoole { };
358     uv = callPackage ../development/php-packages/uv { };
360     vld = callPackage ../development/php-packages/vld { };
362     xdebug = callPackage ../development/php-packages/xdebug { };
364     yaml = callPackage ../development/php-packages/yaml { };
366     zstd = callPackage ../development/php-packages/zstd { };
367   } // lib.optionalAttrs config.allowAliases {
368     php-spx = throw "php-spx is deprecated, use spx instead";
369   } // (
370     # Core extensions
371     let
372       # This list contains build instructions for different modules that one may
373       # want to build.
374       #
375       # These will be passed as arguments to mkExtension above.
376       extensionData = [
377         { name = "bcmath"; }
378         { name = "bz2"; buildInputs = [ bzip2 ]; configureFlags = [ "--with-bz2=${bzip2.dev}" ]; }
379         { name = "calendar"; }
380         { name = "ctype"; }
381         {
382           name = "curl";
383           buildInputs = [ curl ];
384           configureFlags = [ "--with-curl=${curl.dev}" ];
385           doCheck = false;
386         }
387         { name = "dba"; }
388         {
389           name = "dom";
390           buildInputs = [ libxml2 ];
391           configureFlags = [
392             "--enable-dom"
393           ];
394           # Add a PHP lower version bound constraint to avoid applying the patch on older PHP versions.
395           patches = lib.optionals (lib.versions.majorMinor php.version == "8.1") [
396             # Fix tests with libxml 2.12
397             # Part of 8.3.1RC1+, 8.2.14RC1+
398             (fetchpatch {
399               url = "https://github.com/php/php-src/commit/061058a9b1bbd90d27d97d79aebcf2b5029767b0.patch";
400               hash = "sha256-0hOlAG+pOYp/gUU0MUMZvzWpgr0ncJi5GB8IeNxxyEU=";
401               excludes = [
402                 "NEWS"
403               ];
404             })
405           ] ++ lib.optionals (lib.versions.majorMinor php.version == "8.1") [
406             # Backport of PHP_LIBXML_IGNORE_DEPRECATIONS_START and PHP_LIBXML_IGNORE_DEPRECATIONS_END
407             ../development/interpreters/php/php81-fix-libxml2-2.13-compatibility.patch
408             # Fix build with libxml2 2.13+. Has to be applied after libxml2 2.12 patch.
409             (fetchpatch {
410               url = "https://github.com/php/php-src/commit/9b4f6b09d58a4e54ee60443bf9a8b166852c03e0.patch";
411               hash = "sha256-YC3I0BQi3o3+VmRu/UqpqPpaSC+ekPqzbORTHftbPvY=";
412             })
413           ];
414         }
415         {
416           name = "enchant";
417           buildInputs = [ enchant2 ];
418           configureFlags = [ "--with-enchant" ];
419           doCheck = false;
420         }
421         { name = "exif"; doCheck = false; }
422         { name = "ffi"; buildInputs = [ libffi ]; }
423         {
424           name = "fileinfo";
425           buildInputs = [ pcre2 ];
426         }
427         { name = "filter"; buildInputs = [ pcre2 ]; }
428         { name = "ftp"; buildInputs = [ openssl ]; }
429         {
430           name = "gd";
431           buildInputs = [ zlib gd ];
432           configureFlags = [
433             "--enable-gd"
434             "--with-external-gd=${gd.dev}"
435             "--enable-gd-jis-conv"
436           ];
437           doCheck = false;
438         }
439         {
440           name = "gettext";
441           buildInputs = [ gettext ];
442           postPhpize = ''substituteInPlace configure --replace-fail 'as_fn_error $? "Cannot locate header file libintl.h" "$LINENO" 5' ':' '';
443           configureFlags = [ "--with-gettext=${gettext}" ];
444         }
445         {
446           name = "gmp";
447           buildInputs = [ gmp ];
448           configureFlags = [ "--with-gmp=${gmp.dev}" ];
449         }
450         {
451           name = "iconv";
452           buildInputs = [ libiconv ];
453           configureFlags = [ "--with-iconv" ];
454           doCheck = stdenv.hostPlatform.isLinux;
455         }
456         {
457           name = "imap";
458           buildInputs = [ uwimap openssl pam pcre2 libkrb5 ];
459           configureFlags = [ "--with-imap=${uwimap}" "--with-imap-ssl" "--with-kerberos" ];
460           # Using version from PECL on new PHP versions.
461           enable = lib.versionOlder php.version "8.3";
462         }
463         {
464           name = "intl";
465           buildInputs = [ icu73 ];
466         }
467         {
468           name = "ldap";
469           buildInputs = [ openldap cyrus_sasl ];
470           configureFlags = [
471             "--with-ldap"
472             "LDAP_DIR=${openldap.dev}"
473             "LDAP_INCDIR=${openldap.dev}/include"
474             "LDAP_LIBDIR=${openldap.out}/lib"
475           ] ++ lib.optionals stdenv.hostPlatform.isLinux [
476             "--with-ldap-sasl=${cyrus_sasl.dev}"
477           ];
478           doCheck = false;
479         }
480         {
481           name = "mbstring";
482           buildInputs = [ oniguruma pcre2 ];
483           doCheck = false;
484         }
485         {
486           name = "mysqli";
487           internalDeps = [ php.extensions.mysqlnd ];
488           configureFlags = [ "--with-mysqli=mysqlnd" "--with-mysql-sock=/run/mysqld/mysqld.sock" ];
489           doCheck = false;
490         }
491         {
492           name = "mysqlnd";
493           buildInputs = [ zlib openssl ];
494           # The configure script doesn't correctly add library link
495           # flags, so we add them to the variable used by the Makefile
496           # when linking.
497           MYSQLND_SHARED_LIBADD = "-lz -lssl -lcrypto";
498           # The configure script builds a config.h which is never
499           # included. Let's include it in the main header file
500           # included by all .c-files.
501           patches = [
502             (pkgs.writeText "mysqlnd_config.patch" ''
503               --- a/ext/mysqlnd/mysqlnd.h
504               +++ b/ext/mysqlnd/mysqlnd.h
505               @@ -1,3 +1,6 @@
506               +#ifdef HAVE_CONFIG_H
507               +#include "config.h"
508               +#endif
509                /*
510                  +----------------------------------------------------------------------+
511                  | Copyright (c) The PHP Group                                          |
512             '')
513           ];
514         }
515         {
516           name = "opcache";
517           buildInputs = [ pcre2 ] ++
518             lib.optional
519               (!stdenv.hostPlatform.isDarwin && lib.meta.availableOn stdenv.hostPlatform valgrind)
520               valgrind.dev;
521           configureFlags = lib.optional php.ztsSupport "--disable-opcache-jit";
522           zendExtension = true;
523           postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
524             # Tests are flaky on darwin
525             rm ext/opcache/tests/blacklist.phpt
526             rm ext/opcache/tests/bug66338.phpt
527             rm ext/opcache/tests/bug78106.phpt
528             rm ext/opcache/tests/issue0115.phpt
529             rm ext/opcache/tests/issue0149.phpt
530             rm ext/opcache/tests/revalidate_path_01.phpt
531           '';
532           # Tests launch the builtin webserver.
533           __darwinAllowLocalNetworking = true;
534         }
535         {
536           name = "openssl";
537           buildInputs = [ openssl ];
538           configureFlags = [ "--with-openssl" ];
539           doCheck = false;
540         }
541         # This provides a legacy OpenSSL PHP extension
542         # For situations where OpenSSL 3 do not support a set of features
543         # without a specific openssl.cnf file
544         {
545           name = "openssl-legacy";
546           extName = "openssl";
547           buildInputs = [ openssl_1_1 ];
548           configureFlags = [ "--with-openssl" ];
549           doCheck = false;
550         }
551         { name = "pcntl"; }
552         { name = "pdo"; doCheck = false; }
553         {
554           name = "pdo_dblib";
555           internalDeps = [ php.extensions.pdo ];
556           configureFlags = [ "--with-pdo-dblib=${freetds}" ];
557           # Doesn't seem to work on darwin.
558           enable = (!stdenv.hostPlatform.isDarwin);
559           doCheck = false;
560         }
561         {
562           name = "pdo_mysql";
563           internalDeps = with php.extensions; [ pdo mysqlnd ];
564           configureFlags = [ "--with-pdo-mysql=mysqlnd" "PHP_MYSQL_SOCK=/run/mysqld/mysqld.sock" ];
565           doCheck = false;
566         }
567         {
568           name = "pdo_odbc";
569           internalDeps = [ php.extensions.pdo ];
570           buildInputs = [ unixODBC ];
571           configureFlags = [ "--with-pdo-odbc=unixODBC,${unixODBC}" ];
572           doCheck = false;
573         }
574         {
575           name = "pdo_pgsql";
576           internalDeps = [ php.extensions.pdo ];
577           configureFlags = [ "--with-pdo-pgsql=${lib.getDev postgresql}" ];
578           doCheck = false;
579         }
580         {
581           name = "pdo_sqlite";
582           internalDeps = [ php.extensions.pdo ];
583           buildInputs = [ sqlite ];
584           configureFlags = [ "--with-pdo-sqlite=${sqlite.dev}" ];
585           doCheck = false;
586         }
587         {
588           name = "pgsql";
589           buildInputs = [ pcre2 ];
590           configureFlags = [ "--with-pgsql=${lib.getDev postgresql}" ];
591           doCheck = false;
592         }
593         { name = "posix"; doCheck = false; }
594         {
595           name = "readline";
596           buildInputs = [
597             readline
598           ];
599           configureFlags = [
600             "--with-readline=${readline.dev}"
601           ];
602           postPatch = ''
603             # Fix `--with-readline` option not being available.
604             # `PHP_ALWAYS_SHARED` generated by phpize enables all options
605             # without the possibility to override them. But when `--with-libedit`
606             # is enabled, `--with-readline` is not registered.
607             echo '
608             AC_DEFUN([PHP_ALWAYS_SHARED],[
609               test "[$]$1" != "no" && ext_shared=yes
610             ])dnl
611             ' | cat - ext/readline/config.m4 > ext/readline/config.m4.tmp
612             mv ext/readline/config.m4{.tmp,}
613           '';
614           doCheck = false;
615         }
616         { name = "session";
617           doCheck = false;
618         }
619         { name = "shmop"; }
620         {
621           name = "simplexml";
622           buildInputs = [ libxml2 pcre2 ];
623           configureFlags = [
624             "--enable-simplexml"
625           ];
626           patches = lib.optionals (lib.versions.majorMinor php.version == "8.1") [
627             # Fix tests with libxml2 2.12
628             (fetchpatch {
629               url = "https://github.com/php/php-src/commit/061058a9b1bbd90d27d97d79aebcf2b5029767b0.patch";
630               hash = "sha256-0hOlAG+pOYp/gUU0MUMZvzWpgr0ncJi5GB8IeNxxyEU=";
631               excludes = [
632                 "NEWS"
633               ];
634             })
635             # Backport of PHP_LIBXML_IGNORE_DEPRECATIONS_START and PHP_LIBXML_IGNORE_DEPRECATIONS_END
636             # Required for libxml2 2.13 compatibility patch.
637             ../development/interpreters/php/php81-fix-libxml2-2.13-compatibility.patch
638             # Fix build with libxml2 2.13+. Has to be applied after libxml2 2.12 patch.
639             (fetchpatch {
640               url = "https://github.com/php/php-src/commit/9b4f6b09d58a4e54ee60443bf9a8b166852c03e0.patch";
641               hash = "sha256-YC3I0BQi3o3+VmRu/UqpqPpaSC+ekPqzbORTHftbPvY=";
642             })
643           ];
644         }
645         {
646           name = "snmp";
647           buildInputs = [ net-snmp openssl ];
648           configureFlags = [ "--with-snmp" ];
649           # net-snmp doesn't build on darwin.
650           enable = (!stdenv.hostPlatform.isDarwin);
651           doCheck = false;
652         }
653         {
654           name = "soap";
655           buildInputs = [ libxml2 ];
656           configureFlags = [
657             "--enable-soap"
658           ];
659           # Some tests are causing issues in the Darwin sandbox with issues
660           # such as
661           #   Unknown: php_network_getaddresses: getaddrinfo for localhost failed: nodename nor servname provided
662           doCheck = !stdenv.hostPlatform.isDarwin;
663           internalDeps = [ php.extensions.session ];
664           patches = lib.optionals (lib.versions.majorMinor php.version == "8.1") [
665             # Fix tests with libxml2 2.12
666             (fetchpatch {
667               url = "https://github.com/php/php-src/commit/061058a9b1bbd90d27d97d79aebcf2b5029767b0.patch";
668               hash = "sha256-0hOlAG+pOYp/gUU0MUMZvzWpgr0ncJi5GB8IeNxxyEU=";
669               excludes = [
670                 "NEWS"
671               ];
672             })
673             # Backport of PHP_LIBXML_IGNORE_DEPRECATIONS_START and PHP_LIBXML_IGNORE_DEPRECATIONS_END
674             # Required for libxml2 2.13 compatibility patch.
675             ../development/interpreters/php/php81-fix-libxml2-2.13-compatibility.patch
676             # Fix build with libxml2 2.13+. Has to be applied after libxml2 2.12 patch.
677             (fetchpatch {
678               url = "https://github.com/php/php-src/commit/9b4f6b09d58a4e54ee60443bf9a8b166852c03e0.patch";
679               hash = "sha256-YC3I0BQi3o3+VmRu/UqpqPpaSC+ekPqzbORTHftbPvY=";
680             })
681           ];
682         }
683         {
684           name = "sockets";
685           doCheck = false;
686         }
687         { name = "sodium"; buildInputs = [ libsodium ]; }
688         {
689           name = "sqlite3";
690           buildInputs = [ sqlite ];
692           # The `sqlite3_bind_bug68849.phpt` test is currently broken for i686 Linux systems since sqlite 3.43, cf.:
693           # - https://github.com/php/php-src/issues/12076
694           # - https://www.sqlite.org/forum/forumpost/abbb95376ec6cd5f
695           patches = lib.optionals (stdenv.hostPlatform.isi686 && stdenv.hostPlatform.isLinux) [
696             ../development/interpreters/php/skip-sqlite3_bind_bug68849.phpt.patch
697           ];
698         }
699         { name = "sysvmsg"; }
700         { name = "sysvsem"; }
701         { name = "sysvshm"; }
702         { name = "tidy"; configureFlags = [ "--with-tidy=${html-tidy}" ]; doCheck = false; }
703         {
704           name = "tokenizer";
705           patches = [ ../development/interpreters/php/fix-tokenizer-php81.patch ];
706         }
707         {
708           name = "xml";
709           buildInputs = [ libxml2 ];
710           configureFlags = [
711             "--enable-xml"
712           ];
713           doCheck = false;
714           patches = lib.optionals (lib.versions.majorMinor php.version == "8.1") [
715             # Fix tests with libxml2 2.12
716             (fetchpatch {
717               url = "https://github.com/php/php-src/commit/061058a9b1bbd90d27d97d79aebcf2b5029767b0.patch";
718               hash = "sha256-0hOlAG+pOYp/gUU0MUMZvzWpgr0ncJi5GB8IeNxxyEU=";
719               excludes = [
720                 "NEWS"
721               ];
722             })
723             # Backport of PHP_LIBXML_IGNORE_DEPRECATIONS_START and PHP_LIBXML_IGNORE_DEPRECATIONS_END
724             # Required for libxml2 2.13 compatibility patch.
725             ../development/interpreters/php/php81-fix-libxml2-2.13-compatibility.patch
726             # Fix build with libxml2 2.13+. Has to be applied after libxml2 2.12 patch.
727             (fetchpatch {
728               url = "https://github.com/php/php-src/commit/9b4f6b09d58a4e54ee60443bf9a8b166852c03e0.patch";
729               hash = "sha256-YC3I0BQi3o3+VmRu/UqpqPpaSC+ekPqzbORTHftbPvY=";
730             })
731           ];
732         }
733         {
734           name = "xmlreader";
735           buildInputs = [ libxml2 ];
736           internalDeps = [ php.extensions.dom ];
737           env.NIX_CFLAGS_COMPILE = toString [ "-I../.." "-DHAVE_DOM" ];
738           doCheck = false;
739           configureFlags = [
740             "--enable-xmlreader"
741           ];
742         }
743         {
744           name = "xmlwriter";
745           buildInputs = [ libxml2 ];
746           configureFlags = [
747             "--enable-xmlwriter"
748           ];
749           patches = lib.optionals (lib.versions.majorMinor php.version == "8.1") [
750             # Fix tests with libxml2 2.12
751             (fetchpatch {
752               url = "https://github.com/php/php-src/commit/061058a9b1bbd90d27d97d79aebcf2b5029767b0.patch";
753               hash = "sha256-0hOlAG+pOYp/gUU0MUMZvzWpgr0ncJi5GB8IeNxxyEU=";
754               excludes = [
755                 "NEWS"
756               ];
757             })
758             # Backport of PHP_LIBXML_IGNORE_DEPRECATIONS_START and PHP_LIBXML_IGNORE_DEPRECATIONS_END
759             # Required for libxml2 2.13 compatibility patch.
760             ../development/interpreters/php/php81-fix-libxml2-2.13-compatibility.patch
761             # Fix build with libxml2 2.13+. Has to be applied after libxml2 2.12 patch.
762             (fetchpatch {
763               url = "https://github.com/php/php-src/commit/9b4f6b09d58a4e54ee60443bf9a8b166852c03e0.patch";
764               hash = "sha256-YC3I0BQi3o3+VmRu/UqpqPpaSC+ekPqzbORTHftbPvY=";
765             })
766           ];
767         }
768         {
769           name = "xsl";
770           buildInputs = [ libxslt libxml2 ];
771           internalDeps = [ php.extensions.dom ];
772           doCheck = false;
773           env.NIX_CFLAGS_COMPILE = toString [ "-I../.." "-DHAVE_DOM" ];
774           configureFlags = [ "--with-xsl=${libxslt.dev}" ];
775         }
776         {
777           name = "zend_test";
778           internalDeps = [ php.extensions.dom ];
779           env.NIX_CFLAGS_COMPILE = "-I${libxml2.dev}/include/libxml2";
780         }
781         {
782           name = "zip";
783           buildInputs = [ libzip pcre2 ];
784           configureFlags = [
785             "--with-zip"
786           ];
787           doCheck = false;
788         }
789         {
790           name = "zlib";
791           buildInputs = [ zlib ];
792           configureFlags = [
793             "--with-zlib"
794           ];
795         }
796       ];
798       # Convert the list of attrs:
799       # [ { name = <name>; ... } ... ]
800       # to a list of
801       # [ { name = <name>; value = <extension drv>; } ... ]
802       #
803       # which we later use listToAttrs to make all attrs available by name.
804       #
805       # Also filter out extensions based on the enable property.
806       namedExtensions = builtins.map
807         (drv: {
808           name = drv.name;
809           value = mkExtension (builtins.removeAttrs drv [ "enable" ]);
810         })
811         (builtins.filter (i: i.enable or true) extensionData);
813       # Produce the final attribute set of all extensions defined.
814     in
815     builtins.listToAttrs namedExtensions
816   );