python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / top-level / php-packages.nix
blob0b9f4237327b067067fd6a87bac2e9a4cea84282
1 { stdenv
2 , lib
3 , pkgs
4 , fetchgit
5 , phpPackage
6 , autoconf
7 , pkg-config
8 , aspell
9 , bzip2
10 , curl
11 , cyrus_sasl
12 , enchant1
13 , fetchpatch
14 , freetds
15 , freetype
16 , gd
17 , gettext
18 , gmp
19 , html-tidy
20 , icu64
21 , libXpm
22 , libffi
23 , libiconv
24 , libjpeg
25 , libkrb5
26 , libpng
27 , libsodium
28 , libwebp
29 , libxml2
30 , libxslt
31 , libzip
32 , net-snmp
33 , oniguruma
34 , openldap
35 , openssl_1_1
36 , openssl
37 , pam
38 , pcre2
39 , postgresql
40 , re2c
41 , readline
42 , rsync
43 , sqlite
44 , unixODBC
45 , uwimap
46 , valgrind
47 , zlib
50 lib.makeScope pkgs.newScope (self: with self; {
51   buildPecl = import ../build-support/build-pecl.nix {
52     php = php.unwrapped;
53     inherit lib;
54     inherit (pkgs) stdenv autoreconfHook fetchurl re2c;
55   };
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;
62   });
64   # Function to build an extension which is shipped as part of the php
65   # source, based on the php version.
66   #
67   # Name passed is the name of the extension and is automatically used
68   # to add the configureFlag "--enable-${name}", which can be overriden.
69   #
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
73     ({ name
74     , configureFlags ? [ "--enable-${name}" ]
75     , internalDeps ? [ ]
76     , postPhpize ? ""
77     , buildInputs ? [ ]
78     , zendExtension ? false
79     , doCheck ? true
80     , ...
81     }@args: stdenv.mkDerivation ((builtins.removeAttrs args [ "name" ]) // {
82       pname = "php-${name}";
83       extensionName = name;
85       outputs = [ "out" "dev" ];
87       inherit (php.unwrapped) version src;
89       enableParallelBuilding = true;
91       nativeBuildInputs = [
92         php.unwrapped
93         autoconf
94         pkg-config
95         re2c
96       ];
98       inherit configureFlags internalDeps buildInputs zendExtension doCheck;
100       preConfigurePhases = [
101         "cdToExtensionRootPhase"
102       ];
104       cdToExtensionRootPhase = ''
105         # Go to extension source root.
106         cd "ext/${name}"
107       '';
109       preConfigure = ''
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
116         fi
118         $nullglobRestore
120         phpize
121         ${postPhpize}
123         ${lib.concatMapStringsSep
124           "\n"
125           (dep: "mkdir -p ext; ln -s ${dep.dev}/include ext/${dep.extensionName}")
126           internalDeps
127         }
128       '';
130       checkPhase = ''
131         runHook preCheck
133         NO_INTERACTON=yes SKIP_PERF_SENSITIVE=yes make test
135         runHook postCheck
136       '';
138       installPhase = ''
139         runHook preInstall
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="+ */" \
145                               --filter="+ *.h" \
146                               --filter="- *" \
147                               --prune-empty-dirs \
148                               . $dev/include/
150         runHook postInstall
151       '';
153       meta = {
154         description = "PHP upstream extension: ${name}";
155         inherit (php.meta) maintainers homepage license;
156       };
157     }));
159   php = phpPackage;
161   # This is a set of interactive tools based on PHP.
162   tools = {
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 { };
190   };
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
196   # interpreter.
197   extensions = {
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;
243       pname = "pdo_oci";
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 ];
251       postPatch = ''
252         sed -i -e 's|OCISDKMANINC=`.*$|OCISDKMANINC="${pkgs.oracle-instantclient.dev}/include"|' config.m4
253       '';
255       meta.maintainers = lib.teams.php.members;
256     };
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 { };
279   } // (
280     let
281       # This list contains build instructions for different modules that one may
282       # want to build.
283       #
284       # These will be passed as arguments to mkExtension above.
285       extensionData = [
286         { name = "bcmath"; }
287         { name = "bz2"; buildInputs = [ bzip2 ]; configureFlags = [ "--with-bz2=${bzip2.dev}" ]; }
288         { name = "calendar"; }
289         { name = "ctype"; }
290         {
291           name = "curl";
292           buildInputs = [ curl ];
293           configureFlags = [ "--with-curl=${curl.dev}" ];
294           doCheck = false;
295         }
296         { name = "dba"; }
297         {
298           name = "dom";
299           buildInputs = [ libxml2 ];
300           configureFlags = [
301             "--enable-dom"
302           ];
303         }
304         {
305           name = "enchant";
306           buildInputs = [ enchant1 ];
307           configureFlags = [ "--with-enchant=${enchant1}" ];
308           # enchant1 doesn't build on darwin.
309           enable = (!stdenv.isDarwin);
310           doCheck = false;
311         }
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 ]; }
317         {
318           name = "gd";
319           buildInputs = [ zlib gd ];
320           configureFlags = [
321             "--enable-gd"
322             "--with-external-gd=${gd.dev}"
323             "--enable-gd-jis-conv"
324           ];
325           doCheck = false;
326         }
327         {
328           name = "gettext";
329           buildInputs = [ gettext ];
330           postPhpize = ''substituteInPlace configure --replace 'as_fn_error $? "Cannot locate header file libintl.h" "$LINENO" 5' ':' '';
331           configureFlags = [ "--with-gettext=${gettext}" ];
332         }
333         {
334           name = "gmp";
335           buildInputs = [ gmp ];
336           configureFlags = [ "--with-gmp=${gmp.dev}" ];
337         }
338         {
339           name = "iconv";
340           configureFlags = [
341             "--with-iconv${lib.optionalString stdenv.isDarwin "=${libiconv}"}"
342           ];
343           doCheck = false;
344         }
345         {
346           name = "imap";
347           buildInputs = [ uwimap openssl pam pcre2 libkrb5 ];
348           configureFlags = [ "--with-imap=${uwimap}" "--with-imap-ssl" "--with-kerberos" ];
349         }
350         {
351           name = "intl";
352           buildInputs = [ icu64 ];
353         }
354         {
355           name = "ldap";
356           buildInputs = [ openldap cyrus_sasl ];
357           configureFlags = [
358             "--with-ldap"
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}"
364           ];
365           doCheck = false;
366         }
367         {
368           name = "mbstring";
369           buildInputs = [ oniguruma pcre2 ];
370           doCheck = false;
371         }
372         {
373           name = "mysqli";
374           internalDeps = [ php.extensions.mysqlnd ];
375           configureFlags = [ "--with-mysqli=mysqlnd" "--with-mysql-sock=/run/mysqld/mysqld.sock" ];
376           doCheck = false;
377         }
378         {
379           name = "mysqlnd";
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
383           # when linking.
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.
388           patches = [
389             (pkgs.writeText "mysqlnd_config.patch" ''
390               --- a/ext/mysqlnd/mysqlnd.h
391               +++ b/ext/mysqlnd/mysqlnd.h
392               @@ -1,3 +1,6 @@
393               +#ifdef HAVE_CONFIG_H
394               +#include "config.h"
395               +#endif
396                /*
397                  +----------------------------------------------------------------------+
398                  | Copyright (c) The PHP Group                                          |
399             '')
400           ];
401         }
402         {
403           name = "opcache";
404           buildInputs = [ pcre2 ] ++ lib.optionals (!stdenv.isDarwin) [
405             valgrind.dev
406           ];
407           zendExtension = true;
408           # Tests launch the builtin webserver.
409           __darwinAllowLocalNetworking = true;
410         }
411         {
412           name = "openssl";
413           buildInputs = if (lib.versionAtLeast php.version "8.1") then [ openssl ] else [ openssl_1_1 ];
414           configureFlags = [ "--with-openssl" ];
415           doCheck = false;
416         }
417         { name = "pcntl"; }
418         { name = "pdo"; doCheck = false; }
419         {
420           name = "pdo_dblib";
421           internalDeps = [ php.extensions.pdo ];
422           configureFlags = [ "--with-pdo-dblib=${freetds}" ];
423           # Doesn't seem to work on darwin.
424           enable = (!stdenv.isDarwin);
425           doCheck = false;
426         }
427         {
428           name = "pdo_mysql";
429           internalDeps = with php.extensions; [ pdo mysqlnd ];
430           configureFlags = [ "--with-pdo-mysql=mysqlnd" "PHP_MYSQL_SOCK=/run/mysqld/mysqld.sock" ];
431           doCheck = false;
432         }
433         {
434           name = "pdo_odbc";
435           internalDeps = [ php.extensions.pdo ];
436           configureFlags = [ "--with-pdo-odbc=unixODBC,${unixODBC}" ];
437           doCheck = false;
438         }
439         {
440           name = "pdo_pgsql";
441           internalDeps = [ php.extensions.pdo ];
442           configureFlags = [ "--with-pdo-pgsql=${postgresql}" ];
443           doCheck = false;
444         }
445         {
446           name = "pdo_sqlite";
447           internalDeps = [ php.extensions.pdo ];
448           buildInputs = [ sqlite ];
449           configureFlags = [ "--with-pdo-sqlite=${sqlite.dev}" ];
450           doCheck = false;
451         }
452         {
453           name = "pgsql";
454           buildInputs = [ pcre2 ];
455           configureFlags = [ "--with-pgsql=${postgresql}" ];
456           doCheck = false;
457         }
458         { name = "posix"; doCheck = false; }
459         { name = "pspell"; configureFlags = [ "--with-pspell=${aspell}" ]; }
460         {
461           name = "readline";
462           buildInputs = [
463             readline
464           ];
465           configureFlags = [
466             "--with-readline=${readline.dev}"
467           ];
468           postPatch = ''
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.
473             echo '
474             AC_DEFUN([PHP_ALWAYS_SHARED],[
475               test "[$]$1" != "no" && ext_shared=yes
476             ])dnl
477             ' | cat - ext/readline/config.m4 > ext/readline/config.m4.tmp
478             mv ext/readline/config.m4{.tmp,}
479           '';
480           doCheck = false;
481         }
482         { name = "session"; doCheck = false; }
483         { name = "shmop"; }
484         {
485           name = "simplexml";
486           buildInputs = [ libxml2 pcre2 ];
487           configureFlags = [
488             "--enable-simplexml"
489           ];
490         }
491         {
492           name = "snmp";
493           buildInputs = [ net-snmp openssl ];
494           configureFlags = [ "--with-snmp" ];
495           # net-snmp doesn't build on darwin.
496           enable = (!stdenv.isDarwin);
497           doCheck = false;
498         }
499         {
500           name = "soap";
501           buildInputs = [ libxml2 ];
502           configureFlags = [
503             "--enable-soap"
504           ];
505           doCheck = false;
506         }
507         {
508           name = "sockets";
509           doCheck = false;
510         }
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; }
517         {
518           name = "tokenizer";
519           patches = lib.optional (lib.versionAtLeast php.version "8.1")
520             ../development/interpreters/php/fix-tokenizer-php81.patch;
521         }
522         {
523           name = "xml";
524           buildInputs = [ libxml2 ];
525           configureFlags = [
526             "--enable-xml"
527           ];
528           doCheck = false;
529         }
530         {
531           name = "xmlreader";
532           buildInputs = [ libxml2 ];
533           internalDeps = [ php.extensions.dom ];
534           NIX_CFLAGS_COMPILE = [ "-I../.." "-DHAVE_DOM" ];
535           doCheck = false;
536           configureFlags = [
537             "--enable-xmlreader"
538           ];
539         }
540         {
541           name = "xmlwriter";
542           buildInputs = [ libxml2 ];
543           configureFlags = [
544             "--enable-xmlwriter"
545           ];
546         }
547         {
548           name = "xsl";
549           buildInputs = [ libxslt libxml2 ];
550           doCheck = false;
551           configureFlags = [ "--with-xsl=${libxslt.dev}" ];
552         }
553         { name = "zend_test"; }
554         {
555           name = "zip";
556           buildInputs = [ libzip pcre2 ];
557           configureFlags = [
558             "--with-zip"
559           ];
560           doCheck = false;
561         }
562         {
563           name = "zlib";
564           buildInputs = [ zlib ];
565           configureFlags = [
566             "--with-zlib"
567           ];
568         }
569       ];
571       # Convert the list of attrs:
572       # [ { name = <name>; ... } ... ]
573       # to a list of
574       # [ { name = <name>; value = <extension drv>; } ... ]
575       #
576       # which we later use listToAttrs to make all attrs available by name.
577       #
578       # Also filter out extensions based on the enable property.
579       namedExtensions = builtins.map
580         (drv: {
581           name = drv.name;
582           value = mkExtension drv;
583         })
584         (builtins.filter (i: i.enable or true) extensionData);
586       # Produce the final attribute set of all extensions defined.
587     in
588     builtins.listToAttrs namedExtensions
589   );