aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/development/interpreters/php
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
committerMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
commitc4625b175f8200f643fd6e11010932ea44c78433 (patch)
treebce3f89888c8ac3991fa5569a878a9eab6801ccc /infra/libkookie/nixpkgs/pkgs/development/interpreters/php
parent49f735974dd103039ddc4cb576bb76555164a9e7 (diff)
parentd661aa56a8843e991261510c1bb28fdc2f6975ae (diff)
Add 'infra/libkookie/' from commit 'd661aa56a8843e991261510c1bb28fdc2f6975ae'
git-subtree-dir: infra/libkookie git-subtree-mainline: 49f735974dd103039ddc4cb576bb76555164a9e7 git-subtree-split: d661aa56a8843e991261510c1bb28fdc2f6975ae
Diffstat (limited to 'infra/libkookie/nixpkgs/pkgs/development/interpreters/php')
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/interpreters/php/default.nix304
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/interpreters/php/fix-paths-php7.patch26
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/interpreters/php/php73-darwin-isfinite.patch60
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/interpreters/php/zlib-darwin-tests.patch44
4 files changed, 434 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/pkgs/development/interpreters/php/default.nix b/infra/libkookie/nixpkgs/pkgs/development/interpreters/php/default.nix
new file mode 100644
index 000000000000..dd296eb10d84
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/interpreters/php/default.nix
@@ -0,0 +1,304 @@
+# We have tests for PCRE and PHP-FPM in nixos/tests/php/ or
+# both in the same attribute named nixosTests.php
+
+{ callPackage, lib, stdenv, nixosTests }@_args:
+
+let
+ generic =
+ { callPackage, lib, stdenv, nixosTests, config, fetchurl, makeWrapper
+ , symlinkJoin, writeText, autoconf, automake, bison, flex, libtool
+ , pkgconfig, re2c, apacheHttpd, libargon2, libxml2, pcre, pcre2
+ , systemd, system-sendmail, valgrind, xcbuild
+
+ , version
+ , sha256
+ , extraPatches ? []
+
+ # Sapi flags
+ , cgiSupport ? true
+ , cliSupport ? true
+ , fpmSupport ? true
+ , pearSupport ? true
+ , pharSupport ? true
+ , phpdbgSupport ? true
+
+ # Misc flags
+ , apxs2Support ? !stdenv.isDarwin
+ , argon2Support ? true
+ , cgotoSupport ? false
+ , embedSupport ? false
+ , ipv6Support ? true
+ , systemdSupport ? stdenv.isLinux
+ , valgrindSupport ? true
+ , ztsSupport ? apxs2Support
+ }@args:
+ let
+ # buildEnv wraps php to provide additional extensions and
+ # configuration. Its usage is documented in
+ # doc/languages-frameworks/php.section.md.
+ #
+ # Create a buildEnv with earlier overridden values and
+ # extensions functions in its closure. This is necessary for
+ # consecutive calls to buildEnv and overrides to work as
+ # expected.
+ mkBuildEnv = prevArgs: prevExtensionFunctions: lib.makeOverridable (
+ { extensions ? ({ enabled, ... }: enabled), extraConfig ? "", ... }@innerArgs:
+ let
+ allArgs = args // prevArgs // innerArgs;
+ filteredArgs = builtins.removeAttrs allArgs [ "extensions" "extraConfig" ];
+ php = generic filteredArgs;
+
+ php-packages = (callPackage ../../../top-level/php-packages.nix {
+ php = phpWithExtensions;
+ });
+
+ allExtensionFunctions = prevExtensionFunctions ++ [ extensions ];
+ enabledExtensions =
+ builtins.foldl'
+ (enabled: f:
+ f { inherit enabled; all = php-packages.extensions; })
+ []
+ allExtensionFunctions;
+
+ getExtName = ext: lib.removePrefix "php-" (builtins.parseDrvName ext.name).name;
+
+ # Recursively get a list of all internal dependencies
+ # for a list of extensions.
+ getDepsRecursively = extensions:
+ let
+ deps = lib.concatMap
+ (ext: (ext.internalDeps or []) ++ (ext.peclDeps or []))
+ extensions;
+ in
+ if ! (deps == []) then
+ deps ++ (getDepsRecursively deps)
+ else
+ deps;
+
+ # Generate extension load configuration snippets from the
+ # extension parameter. This is an attrset suitable for use
+ # with textClosureList, which is used to put the strings in
+ # the right order - if a plugin which is dependent on
+ # another plugin is placed before its dependency, it will
+ # fail to load.
+ extensionTexts =
+ lib.listToAttrs
+ (map (ext:
+ let
+ extName = getExtName ext;
+ phpDeps = (ext.internalDeps or []) ++ (ext.peclDeps or []);
+ type = "${lib.optionalString (ext.zendExtension or false) "zend_"}extension";
+ in
+ lib.nameValuePair extName {
+ text = "${type}=${ext}/lib/php/extensions/${extName}.so";
+ deps = map getExtName phpDeps;
+ })
+ (enabledExtensions ++ (getDepsRecursively enabledExtensions)));
+
+ extNames = map getExtName enabledExtensions;
+ extraInit = writeText "php.ini" ''
+ ${lib.concatStringsSep "\n"
+ (lib.textClosureList extensionTexts extNames)}
+ ${extraConfig}
+ '';
+
+ phpWithExtensions = symlinkJoin rec {
+ name = "php-with-extensions-${version}";
+ inherit (php) version;
+ nativeBuildInputs = [ makeWrapper ];
+ passthru = php.passthru // {
+ buildEnv = mkBuildEnv allArgs allExtensionFunctions;
+ withExtensions = mkWithExtensions allArgs allExtensionFunctions;
+ phpIni = "${phpWithExtensions}/lib/php.ini";
+ unwrapped = php;
+ tests = nixosTests.php;
+ inherit (php-packages) packages extensions buildPecl;
+ meta = php.meta // {
+ outputsToInstall = [ "out" ];
+ };
+ };
+ paths = [ php ];
+ postBuild = ''
+ cp ${extraInit} $out/lib/php.ini
+
+ wrapProgram $out/bin/php --set PHP_INI_SCAN_DIR $out/lib
+
+ if test -e $out/bin/php-fpm; then
+ wrapProgram $out/bin/php-fpm --set PHP_INI_SCAN_DIR $out/lib
+ fi
+ '';
+ };
+ in
+ phpWithExtensions);
+
+ mkWithExtensions = prevArgs: prevExtensionFunctions: extensions:
+ mkBuildEnv prevArgs prevExtensionFunctions { inherit extensions; };
+
+ pcre' = if (lib.versionAtLeast version "7.3") then pcre2 else pcre;
+ in
+ stdenv.mkDerivation {
+ pname = "php";
+
+ inherit version;
+
+ enableParallelBuilding = true;
+
+ nativeBuildInputs = [ autoconf automake bison flex libtool pkgconfig re2c ]
+ ++ lib.optional stdenv.isDarwin xcbuild;
+
+ buildInputs =
+ # PCRE extension
+ [ pcre' ]
+
+ # Enable sapis
+ ++ lib.optional pearSupport [ libxml2.dev ]
+
+ # Misc deps
+ ++ lib.optional apxs2Support apacheHttpd
+ ++ lib.optional argon2Support libargon2
+ ++ lib.optional systemdSupport systemd
+ ++ lib.optional valgrindSupport valgrind
+ ;
+
+ CXXFLAGS = lib.optionalString stdenv.cc.isClang "-std=c++11";
+
+ configureFlags =
+ # Disable all extensions
+ [ "--disable-all" ]
+
+ # PCRE
+ ++ lib.optionals (lib.versionAtLeast version "7.4") [ "--with-external-pcre=${pcre'.dev}" ]
+ ++ lib.optionals (lib.versions.majorMinor version == "7.3") [ "--with-pcre-regex=${pcre'.dev}" ]
+ ++ lib.optionals (lib.versionOlder version "7.3") [ "--with-pcre-regex=${pcre'.dev}" ]
+ ++ [ "PCRE_LIBDIR=${pcre'}" ]
+
+
+ # Enable sapis
+ ++ lib.optional (!cgiSupport) "--disable-cgi"
+ ++ lib.optional (!cliSupport) "--disable-cli"
+ ++ lib.optional fpmSupport "--enable-fpm"
+ ++ lib.optional pearSupport [ "--with-pear" "--enable-xml" "--with-libxml" ]
+ ++ lib.optionals (pearSupport && (lib.versionOlder version "7.4")) [
+ "--enable-libxml"
+ "--with-libxml-dir=${libxml2.dev}"
+ ]
+ ++ lib.optional pharSupport "--enable-phar"
+ ++ lib.optional phpdbgSupport "--enable-phpdbg"
+
+
+ # Misc flags
+ ++ lib.optional apxs2Support "--with-apxs2=${apacheHttpd.dev}/bin/apxs"
+ ++ lib.optional argon2Support "--with-password-argon2=${libargon2}"
+ ++ lib.optional cgotoSupport "--enable-re2c-cgoto"
+ ++ lib.optional embedSupport "--enable-embed"
+ ++ lib.optional (!ipv6Support) "--disable-ipv6"
+ ++ lib.optional systemdSupport "--with-fpm-systemd"
+ ++ lib.optional valgrindSupport "--with-valgrind=${valgrind.dev}"
+ ++ lib.optional ztsSupport "--enable-maintainer-zts"
+
+
+ # Sendmail
+ ++ [ "PROG_SENDMAIL=${system-sendmail}/bin/sendmail" ]
+ ;
+
+ hardeningDisable = [ "bindnow" ];
+
+ preConfigure =
+ # Don't record the configure flags since this causes unnecessary
+ # runtime dependencies
+ ''
+ for i in main/build-defs.h.in scripts/php-config.in; do
+ substituteInPlace $i \
+ --replace '@CONFIGURE_COMMAND@' '(omitted)' \
+ --replace '@CONFIGURE_OPTIONS@' "" \
+ --replace '@PHP_LDFLAGS@' ""
+ done
+
+ export EXTENSION_DIR=$out/lib/php/extensions
+ ''
+ # PKG_CONFIG need not be a relative path
+ + lib.optionalString (! lib.versionAtLeast version "7.4") ''
+ for i in $(find . -type f -name "*.m4"); do
+ substituteInPlace $i \
+ --replace 'test -x "$PKG_CONFIG"' 'type -P "$PKG_CONFIG" >/dev/null'
+ done
+ '' + ''
+ ./buildconf --copy --force
+
+ if test -f $src/genfiles; then
+ ./genfiles
+ fi
+ '' + lib.optionalString stdenv.isDarwin ''
+ substituteInPlace configure --replace "-lstdc++" "-lc++"
+ '';
+
+ postInstall = ''
+ test -d $out/etc || mkdir $out/etc
+ cp php.ini-production $out/etc/php.ini
+ '';
+
+ postFixup = ''
+ mkdir -p $dev/bin $dev/share/man/man1
+ mv $out/bin/phpize $out/bin/php-config $dev/bin/
+ mv $out/share/man/man1/phpize.1.gz \
+ $out/share/man/man1/php-config.1.gz \
+ $dev/share/man/man1/
+ '';
+
+ src = fetchurl {
+ url = "https://www.php.net/distributions/php-${version}.tar.bz2";
+ inherit sha256;
+ };
+
+ patches = [ ./fix-paths-php7.patch ] ++ extraPatches;
+
+ separateDebugInfo = true;
+
+ outputs = [ "out" "dev" ];
+
+ passthru = {
+ buildEnv = mkBuildEnv {} [];
+ withExtensions = mkWithExtensions {} [];
+ inherit ztsSupport;
+ };
+
+ meta = with stdenv.lib; {
+ description = "An HTML-embedded scripting language";
+ homepage = "https://www.php.net/";
+ license = licenses.php301;
+ maintainers = teams.php.members;
+ platforms = platforms.all;
+ outputsToInstall = [ "out" "dev" ];
+ };
+ };
+
+ php73base = callPackage generic (_args // {
+ version = "7.3.23";
+ sha256 = "0k600imsxm3r3qdv20ryqhvfmnkmjhvm2hcnqr180l058snncrpx";
+
+ # https://bugs.php.net/bug.php?id=76826
+ extraPatches = lib.optional stdenv.isDarwin ./php73-darwin-isfinite.patch;
+ });
+
+ php74base = callPackage generic (_args // {
+ version = "7.4.11";
+ sha256 = "1idq2sk3x6msy8l2g42jv3y87h1fgb1aybxw7wpjkliv4iaz422l";
+ });
+
+ defaultPhpExtensions = { all, ... }: with all; ([
+ bcmath calendar curl ctype dom exif fileinfo filter ftp gd
+ gettext gmp iconv intl json ldap mbstring mysqli mysqlnd opcache
+ openssl pcntl pdo pdo_mysql pdo_odbc pdo_pgsql pdo_sqlite pgsql
+ posix readline session simplexml sockets soap sodium sqlite3
+ tokenizer xmlreader xmlwriter zip zlib
+ ] ++ lib.optionals (!stdenv.isDarwin) [ imap ]);
+
+ defaultPhpExtensionsWithHash = { all, ... }:
+ (defaultPhpExtensions { inherit all; }) ++ [ all.hash ];
+
+ php74 = php74base.withExtensions defaultPhpExtensions;
+ php73 = php73base.withExtensions defaultPhpExtensionsWithHash;
+
+in {
+ inherit php73 php74;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/development/interpreters/php/fix-paths-php7.patch b/infra/libkookie/nixpkgs/pkgs/development/interpreters/php/fix-paths-php7.patch
new file mode 100644
index 000000000000..908f06ec49ab
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/interpreters/php/fix-paths-php7.patch
@@ -0,0 +1,26 @@
+diff -ru a/ext/gettext/config.m4 b/ext/gettext/config.m4
+--- a/ext/gettext/config.m4 2018-11-07 15:35:26.000000000 +0000
++++ b/ext/gettext/config.m4 2018-11-27 00:33:07.000000000 +0000
+@@ -6,9 +6,7 @@
+ [ --with-gettext[=DIR] Include GNU gettext support])
+
+ if test "$PHP_GETTEXT" != "no"; then
+- for i in $PHP_GETTEXT /usr/local /usr; do
+- test -r $i/include/libintl.h && GETTEXT_DIR=$i && break
+- done
++ GETTEXT_DIR=$PHP_GETTEXT
+
+ if test -z "$GETTEXT_DIR"; then
+ AC_MSG_ERROR(Cannot locate header file libintl.h)
+diff -ru a/sapi/apache2handler/config.m4 b/sapi/apache2handler/config.m4
+--- a/sapi/apache2handler/config.m4 2018-11-07 15:35:23.000000000 +0000
++++ b/sapi/apache2handler/config.m4 2018-11-27 00:32:28.000000000 +0000
+@@ -66,7 +66,7 @@
+ AC_MSG_ERROR([Please note that Apache version >= 2.0.44 is required])
+ fi
+
+- APXS_LIBEXECDIR='$(INSTALL_ROOT)'`$APXS -q LIBEXECDIR`
++ APXS_LIBEXECDIR="$prefix/modules"
+ if test -z `$APXS -q SYSCONFDIR`; then
+ INSTALL_IT="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
+ $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
diff --git a/infra/libkookie/nixpkgs/pkgs/development/interpreters/php/php73-darwin-isfinite.patch b/infra/libkookie/nixpkgs/pkgs/development/interpreters/php/php73-darwin-isfinite.patch
new file mode 100644
index 000000000000..7f784e0f5a95
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/interpreters/php/php73-darwin-isfinite.patch
@@ -0,0 +1,60 @@
+diff -ru a/configure.ac b/configure.ac
+--- a/configure.ac 2018-12-04 19:12:20.000000000 +0300
++++ b/configure.ac 2018-12-10 12:30:37.798917520 +0300
+@@ -68,7 +68,7 @@
+ #include <math.h>
+
+ #ifndef zend_isnan
+-#if HAVE_DECL_ISNAN && (!defined(__cplusplus) || __cplusplus < 201103L)
++#if HAVE_DECL_ISNAN && (defined(__APPLE__) || defined(__APPLE_CC__) || !defined(__cplusplus) || __cplusplus < 201103L)
+ #define zend_isnan(a) isnan(a)
+ #elif defined(HAVE_FPCLASS)
+ #define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
+@@ -77,7 +77,7 @@
+ #endif
+ #endif
+
+-#if HAVE_DECL_ISINF && (!defined(__cplusplus) || __cplusplus < 201103L)
++#if HAVE_DECL_ISINF && (defined(__APPLE__) || defined(__APPLE_CC__) || !defined(__cplusplus) || __cplusplus < 201103L)
+ #define zend_isinf(a) isinf(a)
+ #elif defined(INFINITY)
+ /* Might not work, but is required by ISO C99 */
+@@ -88,7 +88,7 @@
+ #define zend_isinf(a) 0
+ #endif
+
+-#if HAVE_DECL_ISFINITE && (!defined(__cplusplus) || __cplusplus < 201103L)
++#if HAVE_DECL_ISFINITE && (defined(__APPLE__) || defined(__APPLE_CC__) || !defined(__cplusplus) || __cplusplus < 201103L)
+ #define zend_finite(a) isfinite(a)
+ #elif defined(HAVE_FINITE)
+ #define zend_finite(a) finite(a)
+diff -ru a/Zend/configure.ac b/Zend/configure.ac
+--- a/Zend/configure.ac 2018-12-04 19:12:30.000000000 +0300
++++ b/Zend/configure.ac 2018-12-10 12:28:50.350929699 +0300
+@@ -59,7 +59,7 @@
+ #include <math.h>
+
+ #ifndef zend_isnan
+-#if HAVE_DECL_ISNAN && (!defined(__cplusplus) || __cplusplus < 201103L)
++#if HAVE_DECL_ISNAN && (defined(__APPLE__) || defined(__APPLE_CC__) || !defined(__cplusplus) || __cplusplus < 201103L)
+ #define zend_isnan(a) isnan(a)
+ #elif defined(HAVE_FPCLASS)
+ #define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
+@@ -68,7 +68,7 @@
+ #endif
+ #endif
+
+-#if HAVE_DECL_ISINF && (!defined(__cplusplus) || __cplusplus < 201103L)
++#if HAVE_DECL_ISINF && (defined(__APPLE__) || defined(__APPLE_CC__) || !defined(__cplusplus) || __cplusplus < 201103L)
+ #define zend_isinf(a) isinf(a)
+ #elif defined(INFINITY)
+ /* Might not work, but is required by ISO C99 */
+@@ -79,7 +79,7 @@
+ #define zend_isinf(a) 0
+ #endif
+
+-#if HAVE_DECL_ISFINITE && (!defined(__cplusplus) || __cplusplus < 201103L)
++#if HAVE_DECL_ISFINITE && (defined(__APPLE__) || defined(__APPLE_CC__) || !defined(__cplusplus) || __cplusplus < 201103L)
+ #define zend_finite(a) isfinite(a)
+ #elif defined(HAVE_FINITE)
+ #define zend_finite(a) finite(a)
diff --git a/infra/libkookie/nixpkgs/pkgs/development/interpreters/php/zlib-darwin-tests.patch b/infra/libkookie/nixpkgs/pkgs/development/interpreters/php/zlib-darwin-tests.patch
new file mode 100644
index 000000000000..ef61f0a87845
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/interpreters/php/zlib-darwin-tests.patch
@@ -0,0 +1,44 @@
+diff --git a/ext/zlib/tests/bug55544.phpt b/ext/zlib/tests/bug55544.phpt
+index a0d22f4fcebf4846da6781f424f87821626de5ea..e650fe6909f555d04834f4c08f7fd0d354b783e2 100644
+--- a/ext/zlib/tests/bug55544.phpt
++++ b/ext/zlib/tests/bug55544.phpt
+@@ -6,6 +6,9 @@ extension_loaded("zlib") or die("skip");
+ if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die("skip not for windows");
+ }
++if (PHP_OS == "Darwin") {
++ die("skip not for darwin");
++}
+ ?>
+ --INI--
+ output_handler=ob_gzhandler
+diff --git a/ext/zlib/tests/gzencode_variation1.phpt b/ext/zlib/tests/gzencode_variation1.phpt
+index c966b2cbc5b7..2f953168fa22 100644
+--- a/ext/zlib/tests/gzencode_variation1.phpt
++++ b/ext/zlib/tests/gzencode_variation1.phpt
+@@ -10,6 +10,10 @@ if( substr(PHP_OS, 0, 3) == "WIN" ) {
+ if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+ }
++
++if (PHP_OS == "Darwin") {
++ print "skip - OS is encoded in headers, tested header is non Darwin";
++}
+ ?>
+ --FILE--
+ <?php
+diff --git a/ext/zlib/tests/gzencode_variation2.phpt b/ext/zlib/tests/gzencode_variation2.phpt
+index 94ac42a5f1cd..9160cf519751 100644
+--- a/ext/zlib/tests/gzencode_variation2.phpt
++++ b/ext/zlib/tests/gzencode_variation2.phpt
+@@ -10,6 +10,10 @@ if( substr(PHP_OS, 0, 3) == "WIN" ) {
+ if (!extension_loaded("zlib")) {
+ print "skip - ZLIB extension not loaded";
+ }
++
++if (PHP_OS == "Darwin") {
++ print "skip - OS is encoded in headers, tested header is non Darwin";
++}
+ ?>
+ --FILE--
+ <?php