Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at domenkozar-patch-1 603 lines 18 kB view raw
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 48}: 49 50lib.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 }; 56 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 = args.meta // { 62 mainProgram = args.meta.mainProgram or pname; 63 }; 64 }); 65 66 # Function to build an extension which is shipped as part of the php 67 # source, based on the php version. 68 # 69 # Name passed is the name of the extension and is automatically used 70 # to add the configureFlag "--enable-${name}", which can be overridden. 71 # 72 # Build inputs is used for extra deps that may be needed. And zendExtension 73 # will mark the extension as a zend extension or not. 74 mkExtension = lib.makeOverridable 75 ({ name 76 , configureFlags ? [ "--enable-${extName}" ] 77 , internalDeps ? [ ] 78 , postPhpize ? "" 79 , buildInputs ? [ ] 80 , zendExtension ? false 81 , doCheck ? true 82 , extName ? name 83 , ... 84 }@args: stdenv.mkDerivation ((builtins.removeAttrs args [ "name" ]) // { 85 pname = "php-${name}"; 86 extensionName = extName; 87 88 outputs = [ "out" "dev" ]; 89 90 inherit (php.unwrapped) version src; 91 92 enableParallelBuilding = true; 93 94 nativeBuildInputs = [ 95 php.unwrapped 96 autoconf 97 pkg-config 98 re2c 99 ]; 100 101 inherit configureFlags internalDeps buildInputs zendExtension doCheck; 102 103 preConfigurePhases = [ 104 "cdToExtensionRootPhase" 105 ]; 106 107 cdToExtensionRootPhase = '' 108 # Go to extension source root. 109 cd "ext/${extName}" 110 ''; 111 112 preConfigure = '' 113 nullglobRestore=$(shopt -p nullglob) 114 shopt -u nullglob # To make ?-globbing work 115 116 # Some extensions have a config0.m4 or config9.m4 117 if [ -f config?.m4 ]; then 118 mv config?.m4 config.m4 119 fi 120 121 $nullglobRestore 122 123 phpize 124 ${postPhpize} 125 126 ${lib.concatMapStringsSep 127 "\n" 128 (dep: "mkdir -p ext; ln -s ${dep.dev}/include ext/${dep.extensionName}") 129 internalDeps 130 } 131 ''; 132 133 checkPhase = '' 134 runHook preCheck 135 136 NO_INTERACTON=yes SKIP_PERF_SENSITIVE=yes make test 137 138 runHook postCheck 139 ''; 140 141 installPhase = '' 142 runHook preInstall 143 144 mkdir -p $out/lib/php/extensions 145 cp modules/${extName}.so $out/lib/php/extensions/${extName}.so 146 mkdir -p $dev/include 147 ${rsync}/bin/rsync -r --filter="+ */" \ 148 --filter="+ *.h" \ 149 --filter="- *" \ 150 --prune-empty-dirs \ 151 . $dev/include/ 152 153 runHook postInstall 154 ''; 155 156 meta = { 157 description = "PHP upstream extension: ${name}"; 158 inherit (php.meta) maintainers homepage license; 159 }; 160 })); 161 162 php = phpPackage; 163 164 # This is a set of interactive tools based on PHP. 165 tools = { 166 box = callPackage ../development/php-packages/box { }; 167 168 composer = callPackage ../development/php-packages/composer { }; 169 170 deployer = callPackage ../development/php-packages/deployer { }; 171 172 grumphp = callPackage ../development/php-packages/grumphp { }; 173 174 phing = callPackage ../development/php-packages/phing { }; 175 176 phive = callPackage ../development/php-packages/phive { }; 177 178 php-cs-fixer = callPackage ../development/php-packages/php-cs-fixer { }; 179 180 php-parallel-lint = callPackage ../development/php-packages/php-parallel-lint { }; 181 182 phpcbf = callPackage ../development/php-packages/phpcbf { }; 183 184 phpcs = callPackage ../development/php-packages/phpcs { }; 185 186 phpmd = callPackage ../development/php-packages/phpmd { }; 187 188 phpstan = callPackage ../development/php-packages/phpstan { }; 189 190 psalm = callPackage ../development/php-packages/psalm { }; 191 192 psysh = callPackage ../development/php-packages/psysh { }; 193 }; 194 195 196 197 # This is a set of PHP extensions meant to be used in php.buildEnv 198 # or php.withExtensions to extend the functionality of the PHP 199 # interpreter. 200 extensions = { 201 amqp = callPackage ../development/php-packages/amqp { }; 202 203 apcu = callPackage ../development/php-packages/apcu { }; 204 205 ast = callPackage ../development/php-packages/ast { }; 206 207 blackfire = pkgs.callPackage ../development/tools/misc/blackfire/php-probe.nix { inherit php; }; 208 209 couchbase = callPackage ../development/php-packages/couchbase { }; 210 211 datadog_trace = callPackage ../development/php-packages/datadog_trace { }; 212 213 ds = callPackage ../development/php-packages/ds { }; 214 215 event = callPackage ../development/php-packages/event { }; 216 217 gnupg = callPackage ../development/php-packages/gnupg { }; 218 219 grpc = callPackage ../development/php-packages/grpc { }; 220 221 igbinary = callPackage ../development/php-packages/igbinary { }; 222 223 imagick = callPackage ../development/php-packages/imagick { }; 224 225 inotify = callPackage ../development/php-packages/inotify { }; 226 227 mailparse = callPackage ../development/php-packages/mailparse { }; 228 229 maxminddb = callPackage ../development/php-packages/maxminddb { }; 230 231 memcached = callPackage ../development/php-packages/memcached { }; 232 233 mongodb = callPackage ../development/php-packages/mongodb { }; 234 235 oci8 = callPackage ../development/php-packages/oci8 { }; 236 237 openswoole = callPackage ../development/php-packages/openswoole { }; 238 239 pdlib = callPackage ../development/php-packages/pdlib { }; 240 241 pcov = callPackage ../development/php-packages/pcov { }; 242 243 pdo_oci = buildPecl rec { 244 inherit (php.unwrapped) src version; 245 246 pname = "pdo_oci"; 247 sourceRoot = "php-${version}/ext/pdo_oci"; 248 249 buildInputs = [ pkgs.oracle-instantclient ]; 250 configureFlags = [ "--with-pdo-oci=instantclient,${pkgs.oracle-instantclient.lib}/lib" ]; 251 252 internalDeps = [ php.extensions.pdo ]; 253 254 postPatch = '' 255 sed -i -e 's|OCISDKMANINC=`.*$|OCISDKMANINC="${pkgs.oracle-instantclient.dev}/include"|' config.m4 256 ''; 257 258 meta.maintainers = lib.teams.php.members; 259 }; 260 261 pdo_sqlsrv = callPackage ../development/php-packages/pdo_sqlsrv { }; 262 263 pinba = callPackage ../development/php-packages/pinba { }; 264 265 protobuf = callPackage ../development/php-packages/protobuf { }; 266 267 rdkafka = callPackage ../development/php-packages/rdkafka { }; 268 269 redis = callPackage ../development/php-packages/redis { }; 270 271 smbclient = callPackage ../development/php-packages/smbclient { }; 272 273 snuffleupagus = callPackage ../development/php-packages/snuffleupagus { }; 274 275 sqlsrv = callPackage ../development/php-packages/sqlsrv { }; 276 277 swoole = callPackage ../development/php-packages/swoole { }; 278 279 xdebug = callPackage ../development/php-packages/xdebug { }; 280 281 yaml = callPackage ../development/php-packages/yaml { }; 282 } // ( 283 let 284 # This list contains build instructions for different modules that one may 285 # want to build. 286 # 287 # These will be passed as arguments to mkExtension above. 288 extensionData = [ 289 { name = "bcmath"; } 290 { name = "bz2"; buildInputs = [ bzip2 ]; configureFlags = [ "--with-bz2=${bzip2.dev}" ]; } 291 { name = "calendar"; } 292 { name = "ctype"; } 293 { 294 name = "curl"; 295 buildInputs = [ curl ]; 296 configureFlags = [ "--with-curl=${curl.dev}" ]; 297 doCheck = false; 298 } 299 { name = "dba"; } 300 { 301 name = "dom"; 302 buildInputs = [ libxml2 ]; 303 configureFlags = [ 304 "--enable-dom" 305 ]; 306 } 307 { 308 name = "enchant"; 309 buildInputs = [ enchant1 ]; 310 configureFlags = [ "--with-enchant=${enchant1}" ]; 311 # enchant1 doesn't build on darwin. 312 enable = (!stdenv.isDarwin); 313 doCheck = false; 314 } 315 { name = "exif"; doCheck = false; } 316 { name = "ffi"; buildInputs = [ libffi ]; } 317 { name = "fileinfo"; buildInputs = [ pcre2 ]; } 318 { name = "filter"; buildInputs = [ pcre2 ]; } 319 { name = "ftp"; buildInputs = [ openssl ]; } 320 { 321 name = "gd"; 322 buildInputs = [ zlib gd ]; 323 configureFlags = [ 324 "--enable-gd" 325 "--with-external-gd=${gd.dev}" 326 "--enable-gd-jis-conv" 327 ]; 328 doCheck = false; 329 } 330 { 331 name = "gettext"; 332 buildInputs = [ gettext ]; 333 postPhpize = ''substituteInPlace configure --replace 'as_fn_error $? "Cannot locate header file libintl.h" "$LINENO" 5' ':' ''; 334 configureFlags = [ "--with-gettext=${gettext}" ]; 335 } 336 { 337 name = "gmp"; 338 buildInputs = [ gmp ]; 339 configureFlags = [ "--with-gmp=${gmp.dev}" ]; 340 } 341 { 342 name = "iconv"; 343 configureFlags = [ 344 "--with-iconv${lib.optionalString stdenv.isDarwin "=${libiconv}"}" 345 ]; 346 doCheck = false; 347 } 348 { 349 name = "imap"; 350 buildInputs = [ uwimap openssl pam pcre2 libkrb5 ]; 351 configureFlags = [ "--with-imap=${uwimap}" "--with-imap-ssl" "--with-kerberos" ]; 352 } 353 { 354 name = "intl"; 355 buildInputs = [ icu64 ]; 356 } 357 { 358 name = "ldap"; 359 buildInputs = [ openldap cyrus_sasl ]; 360 configureFlags = [ 361 "--with-ldap" 362 "LDAP_DIR=${openldap.dev}" 363 "LDAP_INCDIR=${openldap.dev}/include" 364 "LDAP_LIBDIR=${openldap.out}/lib" 365 ] ++ lib.optionals stdenv.isLinux [ 366 "--with-ldap-sasl=${cyrus_sasl.dev}" 367 ]; 368 doCheck = false; 369 } 370 { 371 name = "mbstring"; 372 buildInputs = [ oniguruma pcre2 ]; 373 doCheck = false; 374 } 375 { 376 name = "mysqli"; 377 internalDeps = [ php.extensions.mysqlnd ]; 378 configureFlags = [ "--with-mysqli=mysqlnd" "--with-mysql-sock=/run/mysqld/mysqld.sock" ]; 379 doCheck = false; 380 } 381 { 382 name = "mysqlnd"; 383 buildInputs = [ zlib openssl ]; 384 # The configure script doesn't correctly add library link 385 # flags, so we add them to the variable used by the Makefile 386 # when linking. 387 MYSQLND_SHARED_LIBADD = "-lssl -lcrypto"; 388 # The configure script builds a config.h which is never 389 # included. Let's include it in the main header file 390 # included by all .c-files. 391 patches = [ 392 (pkgs.writeText "mysqlnd_config.patch" '' 393 --- a/ext/mysqlnd/mysqlnd.h 394 +++ b/ext/mysqlnd/mysqlnd.h 395 @@ -1,3 +1,6 @@ 396 +#ifdef HAVE_CONFIG_H 397 +#include "config.h" 398 +#endif 399 /* 400 +----------------------------------------------------------------------+ 401 | Copyright (c) The PHP Group | 402 '') 403 ]; 404 } 405 { 406 name = "opcache"; 407 buildInputs = [ pcre2 ] ++ lib.optionals (!stdenv.isDarwin) [ 408 valgrind.dev 409 ]; 410 zendExtension = true; 411 # Tests launch the builtin webserver. 412 __darwinAllowLocalNetworking = true; 413 } 414 { 415 name = "openssl"; 416 buildInputs = if (lib.versionAtLeast php.version "8.1") then [ openssl ] else [ openssl_1_1 ]; 417 configureFlags = [ "--with-openssl" ]; 418 doCheck = false; 419 } 420 # This provides a legacy OpenSSL PHP extension 421 # For situations where OpenSSL 3 do not support a set of features 422 # without a specific openssl.cnf file 423 { 424 name = "openssl-legacy"; 425 extName = "openssl"; 426 buildInputs = [ openssl_1_1 ]; 427 configureFlags = [ "--with-openssl" ]; 428 doCheck = false; 429 } 430 { name = "pcntl"; } 431 { name = "pdo"; doCheck = false; } 432 { 433 name = "pdo_dblib"; 434 internalDeps = [ php.extensions.pdo ]; 435 configureFlags = [ "--with-pdo-dblib=${freetds}" ]; 436 # Doesn't seem to work on darwin. 437 enable = (!stdenv.isDarwin); 438 doCheck = false; 439 } 440 { 441 name = "pdo_mysql"; 442 internalDeps = with php.extensions; [ pdo mysqlnd ]; 443 configureFlags = [ "--with-pdo-mysql=mysqlnd" "PHP_MYSQL_SOCK=/run/mysqld/mysqld.sock" ]; 444 doCheck = false; 445 } 446 { 447 name = "pdo_odbc"; 448 internalDeps = [ php.extensions.pdo ]; 449 configureFlags = [ "--with-pdo-odbc=unixODBC,${unixODBC}" ]; 450 doCheck = false; 451 } 452 { 453 name = "pdo_pgsql"; 454 internalDeps = [ php.extensions.pdo ]; 455 configureFlags = [ "--with-pdo-pgsql=${postgresql}" ]; 456 doCheck = false; 457 } 458 { 459 name = "pdo_sqlite"; 460 internalDeps = [ php.extensions.pdo ]; 461 buildInputs = [ sqlite ]; 462 configureFlags = [ "--with-pdo-sqlite=${sqlite.dev}" ]; 463 doCheck = false; 464 } 465 { 466 name = "pgsql"; 467 buildInputs = [ pcre2 ]; 468 configureFlags = [ "--with-pgsql=${postgresql}" ]; 469 doCheck = false; 470 } 471 { name = "posix"; doCheck = false; } 472 { name = "pspell"; configureFlags = [ "--with-pspell=${aspell}" ]; } 473 { 474 name = "readline"; 475 buildInputs = [ 476 readline 477 ]; 478 configureFlags = [ 479 "--with-readline=${readline.dev}" 480 ]; 481 postPatch = '' 482 # Fix `--with-readline` option not being available. 483 # `PHP_ALWAYS_SHARED` generated by phpize enables all options 484 # without the possibility to override them. But when `--with-libedit` 485 # is enabled, `--with-readline` is not registered. 486 echo ' 487 AC_DEFUN([PHP_ALWAYS_SHARED],[ 488 test "[$]$1" != "no" && ext_shared=yes 489 ])dnl 490 ' | cat - ext/readline/config.m4 > ext/readline/config.m4.tmp 491 mv ext/readline/config.m4{.tmp,} 492 ''; 493 doCheck = false; 494 } 495 { name = "session"; doCheck = false; } 496 { name = "shmop"; } 497 { 498 name = "simplexml"; 499 buildInputs = [ libxml2 pcre2 ]; 500 configureFlags = [ 501 "--enable-simplexml" 502 ]; 503 } 504 { 505 name = "snmp"; 506 buildInputs = [ net-snmp openssl ]; 507 configureFlags = [ "--with-snmp" ]; 508 # net-snmp doesn't build on darwin. 509 enable = (!stdenv.isDarwin); 510 doCheck = false; 511 } 512 { 513 name = "soap"; 514 buildInputs = [ libxml2 ]; 515 configureFlags = [ 516 "--enable-soap" 517 ]; 518 doCheck = false; 519 } 520 { 521 name = "sockets"; 522 doCheck = false; 523 } 524 { name = "sodium"; buildInputs = [ libsodium ]; } 525 { name = "sqlite3"; buildInputs = [ sqlite ]; } 526 { name = "sysvmsg"; } 527 { name = "sysvsem"; } 528 { name = "sysvshm"; } 529 { name = "tidy"; configureFlags = [ "--with-tidy=${html-tidy}" ]; doCheck = false; } 530 { 531 name = "tokenizer"; 532 patches = lib.optional (lib.versionAtLeast php.version "8.1") 533 ../development/interpreters/php/fix-tokenizer-php81.patch; 534 } 535 { 536 name = "xml"; 537 buildInputs = [ libxml2 ]; 538 configureFlags = [ 539 "--enable-xml" 540 ]; 541 doCheck = false; 542 } 543 { 544 name = "xmlreader"; 545 buildInputs = [ libxml2 ]; 546 internalDeps = [ php.extensions.dom ]; 547 NIX_CFLAGS_COMPILE = [ "-I../.." "-DHAVE_DOM" ]; 548 doCheck = false; 549 configureFlags = [ 550 "--enable-xmlreader" 551 ]; 552 } 553 { 554 name = "xmlwriter"; 555 buildInputs = [ libxml2 ]; 556 configureFlags = [ 557 "--enable-xmlwriter" 558 ]; 559 } 560 { 561 name = "xsl"; 562 buildInputs = [ libxslt libxml2 ]; 563 doCheck = false; 564 configureFlags = [ "--with-xsl=${libxslt.dev}" ]; 565 } 566 { name = "zend_test"; } 567 { 568 name = "zip"; 569 buildInputs = [ libzip pcre2 ]; 570 configureFlags = [ 571 "--with-zip" 572 ]; 573 doCheck = false; 574 } 575 { 576 name = "zlib"; 577 buildInputs = [ zlib ]; 578 configureFlags = [ 579 "--with-zlib" 580 ]; 581 } 582 ]; 583 584 # Convert the list of attrs: 585 # [ { name = <name>; ... } ... ] 586 # to a list of 587 # [ { name = <name>; value = <extension drv>; } ... ] 588 # 589 # which we later use listToAttrs to make all attrs available by name. 590 # 591 # Also filter out extensions based on the enable property. 592 namedExtensions = builtins.map 593 (drv: { 594 name = drv.name; 595 value = mkExtension drv; 596 }) 597 (builtins.filter (i: i.enable or true) extensionData); 598 599 # Produce the final attribute set of all extensions defined. 600 in 601 builtins.listToAttrs namedExtensions 602 ); 603})