From acfd3859d759f18d5bfd49d33e78114bf3c8ed65 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sat, 6 Jul 2024 17:08:46 +0200 Subject: [PATCH 1/7] php84Extensions.apcu: fix broken test with PHP 8.4 --- pkgs/development/php-packages/apcu/default.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkgs/development/php-packages/apcu/default.nix b/pkgs/development/php-packages/apcu/default.nix index 9cfe9b96cf34..2e8294d0345b 100644 --- a/pkgs/development/php-packages/apcu/default.nix +++ b/pkgs/development/php-packages/apcu/default.nix @@ -1,6 +1,7 @@ { buildPecl, lib, + fetchpatch, pcre2, fetchFromGitHub, }: @@ -19,6 +20,22 @@ buildPecl { sha256 = "sha256-UDKLLCCnYJj/lCD8ZkkDf2WYZMoIbcP75+0/IXo4vdQ="; }; + patches = [ + # Fix broken test (apc_entry_002) with PHP 8.4 alpha1 + # See https://github.com/krakjoe/apcu/issues/510 + (fetchpatch { + url = "https://github.com/krakjoe/apcu/commit/9dad016db50cc46321afec592ea9b49520c1cf13.patch"; + hash = "sha256-8CPUNhEGCVVSXWYridN1+4N4JzCfXZbmUIsPYs/9jfk="; + }) + + # Fix ZTS detection in tests with PHP 8.4 + # https://github.com/krakjoe/apcu/pull/511 + (fetchpatch { + url = "https://github.com/krakjoe/apcu/commit/15766e615264620427c2db37061ca9614d3b7319.patch"; + hash = "sha256-gbSkx47Uo9E28CfJJj4+3ydcw8cXW9NNN/3FuYYTVPY="; + }) + ]; + buildInputs = [ pcre2 ]; doCheck = true; checkTarget = "test"; From 872caa237087d82f7651c21e0d91e907bf8a104b Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sat, 10 Aug 2024 19:09:38 +0200 Subject: [PATCH 2/7] php.extension.blackfire: Clean up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 0006d8ae77677ad3fab03ededd9eb31846646ea7 switched Linux package to downloading individual `.so` files to match Darwin files so we no longer need special casing for that structure – the path will always be `[«system» hash «phpMajor»]`. --- .../tools/misc/blackfire/php-probe.nix | 37 ++++++------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/pkgs/development/tools/misc/blackfire/php-probe.nix b/pkgs/development/tools/misc/blackfire/php-probe.nix index e31984a2c28f..5a49201a8ffb 100644 --- a/pkgs/development/tools/misc/blackfire/php-probe.nix +++ b/pkgs/development/tools/misc/blackfire/php-probe.nix @@ -63,7 +63,6 @@ let let isLinux = builtins.match ".+-linux" system != null; in - assert !isLinux -> (phpMajor != null); fetchurl { url = "https://packages.blackfire.io/binaries/blackfire-php/${version}/blackfire-php-${if isLinux then "linux" else "darwin"}_${hashes.${system}.system}-php-${builtins.replaceStrings [ "." ] [ "" ] phpMajor}.so"; hash = hashes.${system}.hash.${phpMajor}; @@ -114,39 +113,25 @@ stdenv.mkDerivation (finalAttrs: { # All sources for updating by the update script. updateables = let - createName = path: - builtins.replaceStrings [ "." ] [ "_" ] (lib.concatStringsSep "_" path); + createName = { phpMajor, system }: + "php${builtins.replaceStrings [ "." ] [ "" ] phpMajor}_${system}"; - createSourceParams = path: - let - # The path will be either [«system» sha256], or [«system» sha256 «phpMajor» «zts»], - # Let’s skip the sha256. - rest = builtins.tail (builtins.tail path); - in - { - system = - builtins.head path; - phpMajor = - if builtins.length rest == 0 - then null - else builtins.head rest; - }; - - createUpdateable = path: _value: + createUpdateable = sourceParams: lib.nameValuePair - (createName path) + (createName sourceParams) (finalAttrs.finalPackage.overrideAttrs (attrs: { - src = makeSource (createSourceParams path); + src = makeSource sourceParams; })); # Filter out all attributes other than hashes. hashesOnly = lib.filterAttrsRecursive (name: _value: name != "system") hashes; in - builtins.listToAttrs - # Collect all leaf attributes (containing hashes). - (lib.collect - (attrs: attrs ? name) - (lib.mapAttrsRecursive createUpdateable hashesOnly)); + lib.concatMapAttrs ( + system: + { hashes, ... }: + + lib.mapAttrs' (phpMajor: _hash: createUpdateable { inherit phpMajor system; }) + ) hashes; }; meta = { From 5504973e0cc4f8f7d10c8871d67e6cf199e31092 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sat, 10 Aug 2024 19:06:38 +0200 Subject: [PATCH 3/7] php.extensions.blackfire: assert supported version Otherwise, it will fail later on attribute access, which cannot be caught with `builtins.tryEval`. This is presumably important to avoid having CI fail on new PHP versions not yet supported by blackfire. --- .../development/tools/misc/blackfire/php-probe.nix | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkgs/development/tools/misc/blackfire/php-probe.nix b/pkgs/development/tools/misc/blackfire/php-probe.nix index 5a49201a8ffb..8ec0fcac05f9 100644 --- a/pkgs/development/tools/misc/blackfire/php-probe.nix +++ b/pkgs/development/tools/misc/blackfire/php-probe.nix @@ -13,6 +13,7 @@ assert lib.assertMsg (!php.ztsSupport) "blackfire only supports non zts versions let phpMajor = lib.versions.majorMinor php.version; + inherit (stdenv.hostPlatform) system; version = "1.92.21"; @@ -68,14 +69,16 @@ let hash = hashes.${system}.hash.${phpMajor}; }; in + +assert lib.assertMsg (hashes ? ${system}.hash.${phpMajor}) "blackfire does not support PHP version ${phpMajor} on ${system}."; + stdenv.mkDerivation (finalAttrs: { pname = "php-blackfire"; extensionName = "blackfire"; inherit version; src = makeSource { - system = stdenv.hostPlatform.system; - inherit phpMajor; + inherit system phpMajor; }; nativeBuildInputs = lib.optionals stdenv.isLinux [ @@ -122,15 +125,12 @@ stdenv.mkDerivation (finalAttrs: { (finalAttrs.finalPackage.overrideAttrs (attrs: { src = makeSource sourceParams; })); - - # Filter out all attributes other than hashes. - hashesOnly = lib.filterAttrsRecursive (name: _value: name != "system") hashes; in lib.concatMapAttrs ( system: - { hashes, ... }: + { hash, ... }: - lib.mapAttrs' (phpMajor: _hash: createUpdateable { inherit phpMajor system; }) + lib.mapAttrs' (phpMajor: _hash: createUpdateable { inherit phpMajor system; }) hash ) hashes; }; From 1bf9d8abd08b1f22ef1891b3fb0fc7910d94a3a5 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sat, 10 Aug 2024 23:49:32 +0200 Subject: [PATCH 4/7] php.extensions: Filter out enabled attribute So that the packages are not forced to rebuild when `enabled = true` is added. --- pkgs/top-level/php-packages.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/php-packages.nix b/pkgs/top-level/php-packages.nix index de9b83df972e..a39cb293842c 100644 --- a/pkgs/top-level/php-packages.nix +++ b/pkgs/top-level/php-packages.nix @@ -777,7 +777,7 @@ in { namedExtensions = builtins.map (drv: { name = drv.name; - value = mkExtension drv; + value = mkExtension (builtins.removeAttrs drv [ "enable" ]); }) (builtins.filter (i: i.enable or true) extensionData); From b92fa3012473f846eebde0845fcddd3aef8fbef8 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sat, 10 Aug 2024 23:23:31 +0200 Subject: [PATCH 5/7] php.extensions.pspell: Fetch from PECL PHP 8.4 will remove it from tree: https://github.com/php/php-src/commit/b035cb6c8e31bea351f169b3e9f34fdc562e77e1 --- .../php-packages/pspell/default.nix | 32 +++++++++++++++++++ pkgs/top-level/php-packages.nix | 4 +-- 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/php-packages/pspell/default.nix diff --git a/pkgs/development/php-packages/pspell/default.nix b/pkgs/development/php-packages/pspell/default.nix new file mode 100644 index 000000000000..fb8609bca3a3 --- /dev/null +++ b/pkgs/development/php-packages/pspell/default.nix @@ -0,0 +1,32 @@ +{ + aspell, + buildPecl, + fetchFromGitHub, + lib, +}: + +let + version = "1.0.1"; +in +buildPecl { + inherit version; + pname = "pspell"; + + src = fetchFromGitHub { + owner = "php"; + repo = "pecl-text-pspell"; + rev = version; + hash = "sha256-IVBuEVsUKah8W+oVpIPT9Iln6MFox0e5/5Y14/Kgcg4="; + }; + + configureFlags = [ "--with-pspell=${aspell}" ]; + + doCheck = true; + + meta = with lib; { + description = "PHP extension for checking the spelling of a word"; + homepage = "https://pecl.php.net/package/pspell"; + license = licenses.php301; + maintainers = teams.php.members; + }; +} diff --git a/pkgs/top-level/php-packages.nix b/pkgs/top-level/php-packages.nix index a39cb293842c..bd294688cde6 100644 --- a/pkgs/top-level/php-packages.nix +++ b/pkgs/top-level/php-packages.nix @@ -6,7 +6,6 @@ , phpPackage , autoconf , pkg-config -, aspell , bzip2 , curl , cyrus_sasl @@ -324,6 +323,8 @@ in { protobuf = callPackage ../development/php-packages/protobuf { }; + pspell = callPackage ../development/php-packages/pspell { }; + rdkafka = callPackage ../development/php-packages/rdkafka { }; redis = callPackage ../development/php-packages/redis { }; @@ -584,7 +585,6 @@ in { doCheck = false; } { name = "posix"; doCheck = false; } - { name = "pspell"; configureFlags = [ "--with-pspell=${aspell}" ]; } { name = "readline"; buildInputs = [ From a15c71f68481c48a458f06e8c65aefef521c3b59 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sat, 10 Aug 2024 23:29:27 +0200 Subject: [PATCH 6/7] php.extensions.imap: Fetch from PECL PHP 8.4 will remove it from tree: https://github.com/php/php-src/commit/987417e2e081fbead4967088fd55aece3c62ce96 Keeping in-tree versions for PHP < 8.3 since the PECL version does not build there. --- .../development/php-packages/imap/default.nix | 60 +++++++++++++++++++ pkgs/top-level/php-packages.nix | 5 ++ 2 files changed, 65 insertions(+) create mode 100644 pkgs/development/php-packages/imap/default.nix diff --git a/pkgs/development/php-packages/imap/default.nix b/pkgs/development/php-packages/imap/default.nix new file mode 100644 index 000000000000..208130e95158 --- /dev/null +++ b/pkgs/development/php-packages/imap/default.nix @@ -0,0 +1,60 @@ +{ + buildPecl, + fetchFromGitHub, + fetchpatch, + lib, + libkrb5, + openssl, + pam, + pcre2, + pkg-config, + uwimap, +}: + +let + version = "1.0.2"; +in +buildPecl { + inherit version; + pname = "imap"; + + src = fetchFromGitHub { + owner = "php"; + repo = "pecl-mail-imap"; + rev = version; + hash = "sha256-QVeimxm3rfWMvMpSgadhMKd24yPdDGVuhXIOs8668do="; + }; + + patches = [ + # Fix compilation with PHP 8.4. + (fetchpatch { + url = "https://github.com/php/pecl-mail-imap/commit/4fc9970a29c205ec328f36edc8c119c158129324.patch"; + hash = "sha256-MxEaEe4YVeP7W5gDSNJb0thwAhxDj/yRr3qvjlJjRL4="; + }) + ]; + + nativeBuildInputs = [ pkg-config ]; + + buildInputs = [ + uwimap + openssl + pam + pcre2 + libkrb5 + ]; + + configureFlags = [ + "--with-imap=${uwimap}" + "--with-imap-ssl" + "--with-kerberos" + ]; + + doCheck = true; + + meta = with lib; { + description = "PHP extension for checking the spelling of a word"; + homepage = "https://pecl.php.net/package/imap"; + license = licenses.php301; + maintainers = teams.php.members; + }; +} diff --git a/pkgs/top-level/php-packages.nix b/pkgs/top-level/php-packages.nix index bd294688cde6..1c4903915b37 100644 --- a/pkgs/top-level/php-packages.nix +++ b/pkgs/top-level/php-packages.nix @@ -265,6 +265,9 @@ in { imagick = callPackage ../development/php-packages/imagick { }; + # Shadowed by built-in version on PHP < 8.3. + imap = callPackage ../development/php-packages/imap { }; + inotify = callPackage ../development/php-packages/inotify { }; ioncube-loader = callPackage ../development/php-packages/ioncube-loader { }; @@ -453,6 +456,8 @@ in { name = "imap"; buildInputs = [ uwimap openssl pam pcre2 libkrb5 ]; configureFlags = [ "--with-imap=${uwimap}" "--with-imap-ssl" "--with-kerberos" ]; + # Using version from PECL on new PHP versions. + enable = lib.versionOlder php.version "8.3"; } { name = "intl"; From f5c25500e18d5a2913ecec62dd5bc68c7884981c Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Fri, 5 Jul 2024 16:36:46 +0200 Subject: [PATCH 7/7] php84: init at 8.4.0alpha4 https://github.com/php/php-src/blob/php-8.4.0alpha4/NEWS Announcements: - alpha1 https://www.php.net/archive/2024.php#2024-07-05-1 - imap and pspell moved to PECL - alpha3 https://www.php.net/archive/2024.php#2024-07-18-1 - alpha4 https://www.php.net/archive/2024.php#2024-08-01-3 Co-authored-by: Jan Tojnar --- nixos/tests/all-tests.nix | 1 + pkgs/development/interpreters/php/8.4.nix | 61 +++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 10 ++++ pkgs/top-level/php-packages.nix | 8 +++ 4 files changed, 80 insertions(+) create mode 100644 pkgs/development/interpreters/php/8.4.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 12f8954c4040..ffc3408d1652 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -763,6 +763,7 @@ in { php81 = handleTest ./php { php = pkgs.php81; }; php82 = handleTest ./php { php = pkgs.php82; }; php83 = handleTest ./php { php = pkgs.php83; }; + php84 = handleTest ./php { php = pkgs.php84; }; phylactery = handleTest ./web-apps/phylactery.nix {}; pict-rs = handleTest ./pict-rs.nix {}; pinnwand = handleTest ./pinnwand.nix {}; diff --git a/pkgs/development/interpreters/php/8.4.nix b/pkgs/development/interpreters/php/8.4.nix new file mode 100644 index 000000000000..9c6fd1d39288 --- /dev/null +++ b/pkgs/development/interpreters/php/8.4.nix @@ -0,0 +1,61 @@ +{ callPackage, fetchurl, ... }@_args: + +let + base = callPackage ./generic.nix ( + _args + // { + version = "8.4.0alpha4"; + phpSrc = fetchurl { + url = "https://downloads.php.net/~saki/php-8.4.0alpha4.tar.xz"; + hash = "sha256-v411aNKrbteDZnkfpai8SqUgWFQbqZJbzPF5mdCr2Og="; + }; + } + ); +in +base.withExtensions ( + { all, ... }: + with all; + [ + bcmath + calendar + curl + ctype + dom + exif + fileinfo + filter + ftp + gd + gettext + gmp + iconv + intl + ldap + mbstring + mysqli + mysqlnd + opcache + openssl + pcntl + pdo + pdo_mysql + pdo_odbc + pdo_pgsql + pdo_sqlite + pgsql + posix + readline + session + simplexml + sockets + soap + sodium + sysvsem + sqlite3 + tokenizer + xmlreader + xmlwriter + zip + zlib + ] +) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 051d8b0676a6..2e5fd6420ee5 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16854,6 +16854,16 @@ with pkgs; phpExtensions = php.extensions; phpPackages = php.packages; + # Import PHP84 interpreter, extensions and packages + php84 = callPackage ../development/interpreters/php/8.4.nix { + stdenv = if stdenv.cc.isClang then llvmPackages.stdenv else stdenv; + pcre2 = pcre2.override { + withJitSealloc = false; # See https://bugs.php.net/bug.php?id=78927 and https://bugs.php.net/bug.php?id=78630 + }; + }; + php84Extensions = recurseIntoAttrs php84.extensions; + php84Packages = recurseIntoAttrs php84.packages; + # Import PHP83 interpreter, extensions and packages php83 = callPackage ../development/interpreters/php/8.3.nix { stdenv = if stdenv.cc.isClang then llvmPackages.stdenv else stdenv; diff --git a/pkgs/top-level/php-packages.nix b/pkgs/top-level/php-packages.nix index 1c4903915b37..d6d2af5850d0 100644 --- a/pkgs/top-level/php-packages.nix +++ b/pkgs/top-level/php-packages.nix @@ -409,6 +409,14 @@ in { hash = "sha256-sodGODHb4l04P0srn3L8l3K+DjZzCsCNbamfkmIyF+k="; excludes = [ "NEWS" ]; }) + ] ++ lib.optionals (lib.versions.majorMinor php.version == "8.4") [ + # Fix compatibility with libxml2 ≥ 2.13.2 + # https://github.com/php/php-src/issues/15331 + (fetchpatch { + url = "https://github.com/php/php-src/commit/8d7365b6f009ba43e305d6459013ac4fbed7c606.diff?full_index=1"; + hash = "sha256-ct0Ml9kjjcRLryjxMsUQQsDXiDExjpnCnWKf+mYgTsQ="; + excludes = [ "NEWS" ]; + }) ]; } {