From 9f09253e521bbddabd6a7faf5803fffceba7b03c Mon Sep 17 00:00:00 2001 From: talyz Date: Sat, 2 May 2020 23:13:53 +0200 Subject: [PATCH 1/4] php.buildPecl: Allow PECLs to depend on other PECLs Some PECLs depend on other PECLs and, like internal PHP extension dependencies, need to be loaded in the correct order. This makes this possible by adding the argument "peclDeps" to buildPecl, which adds the extension to buildInputs and is treated the same way as internalDeps when the extension config is generated. --- pkgs/build-support/build-pecl.nix | 4 +++- pkgs/development/interpreters/php/default.nix | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/build-pecl.nix b/pkgs/build-support/build-pecl.nix index f43205f24c5..d75d3cf943a 100644 --- a/pkgs/build-support/build-pecl.nix +++ b/pkgs/build-support/build-pecl.nix @@ -3,6 +3,7 @@ { pname , version , internalDeps ? [] +, peclDeps ? [] , buildInputs ? [] , nativeBuildInputs ? [] , postPhpize ? "" @@ -16,11 +17,12 @@ stdenv.mkDerivation (args // { name = "php-${pname}-${version}"; + extensionName = pname; inherit src; nativeBuildInputs = [ autoreconfHook re2c ] ++ nativeBuildInputs; - buildInputs = [ php ] ++ buildInputs; + buildInputs = [ php ] ++ peclDeps ++ buildInputs; makeFlags = [ "EXTENSION_DIR=$(out)/lib/php/extensions" ] ++ makeFlags; diff --git a/pkgs/development/interpreters/php/default.nix b/pkgs/development/interpreters/php/default.nix index ac0ab2196af..8ccb0e54641 100644 --- a/pkgs/development/interpreters/php/default.nix +++ b/pkgs/development/interpreters/php/default.nix @@ -67,7 +67,7 @@ let getDepsRecursively = extensions: let deps = lib.concatMap - (ext: ext.internalDeps or []) + (ext: (ext.internalDeps or []) ++ (ext.peclDeps or [])) extensions; in if ! (deps == []) then @@ -86,12 +86,12 @@ let (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 = lib.optionals (ext ? internalDeps) - (map getExtName ext.internalDeps); + deps = map getExtName phpDeps; }) (enabledExtensions ++ (getDepsRecursively enabledExtensions))); @@ -112,7 +112,7 @@ let phpIni = "${phpWithExtensions}/lib/php.ini"; unwrapped = php; tests = nixosTests.php; - inherit (php-packages) packages extensions; + inherit (php-packages) packages extensions buildPecl; meta = php.meta // { outputsToInstall = [ "out" ]; }; From 295fc2996d57ffef5154e7a632826e08f895a3c5 Mon Sep 17 00:00:00 2001 From: talyz Date: Sat, 2 May 2020 23:16:21 +0200 Subject: [PATCH 2/4] php.extensions.apcu_bc: Fix runtime loading Fix an issue brought up in #86463, where the apcu_bc extension isn't loaded correctly since it produces a .so with a different name than the extension name. Also, the apcu extension has to be loaded and loaded prior to loading this extension. --- pkgs/top-level/php-packages.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/top-level/php-packages.nix b/pkgs/top-level/php-packages.nix index 9532f113ae3..73d436c8077 100644 --- a/pkgs/top-level/php-packages.nix +++ b/pkgs/top-level/php-packages.nix @@ -320,11 +320,16 @@ in sha256 = "0ma00syhk2ps9k9p02jz7rii6x3i2p986il23703zz5npd6y9n20"; + peclDeps = [ php.extensions.apcu ]; + buildInputs = [ - php.extensions.apcu pcre' ]; + postInstall = '' + mv $out/lib/php/extensions/apc.so $out/lib/php/extensions/apcu_bc.so + ''; + meta.maintainers = lib.teams.php.members; }; From 2f1f359692a4af926f5e39653e7ea06f29a4c485 Mon Sep 17 00:00:00 2001 From: talyz Date: Sat, 2 May 2020 23:22:53 +0200 Subject: [PATCH 3/4] php.extensions.pcs: Mark broken in 7.3, add tokenizer dependency The pcs extension fails to load at runtime with PHP 7.3, so let's mark it broken from 7.3 onwards. It also depends on the tokenizer internal extension. --- pkgs/top-level/php-packages.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/top-level/php-packages.nix b/pkgs/top-level/php-packages.nix index 73d436c8077..1f49a145c69 100644 --- a/pkgs/top-level/php-packages.nix +++ b/pkgs/top-level/php-packages.nix @@ -562,8 +562,10 @@ in sha256 = "0d4p1gpl8gkzdiv860qzxfz250ryf0wmjgyc8qcaaqgkdyh5jy5p"; + internalDeps = [ php.extensions.tokenizer ]; + meta.maintainers = lib.teams.php.members; - meta.broken = isPhp74; # Build error + meta.broken = isPhp73; # Runtime failure on 7.3, build error on 7.4 }; pdo_oci = buildPecl rec { From fa4c995d0e8031be38c226284e45fb7d5a97e9a1 Mon Sep 17 00:00:00 2001 From: talyz Date: Sat, 2 May 2020 23:25:41 +0200 Subject: [PATCH 4/4] php.extensions.couchbase: Fix build and runtime loading The couchbase extension depends on the igbinary PECL which needs to be loaded and loaded prior to it. It also seems like the pcs extension isn't actually needed - it at least builds and loads without it. Since the pcs extension dependency was the reason couchbase didn't build on PHP 7.4 it now does, so let's unmark it broken. --- pkgs/top-level/php-packages.nix | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pkgs/top-level/php-packages.nix b/pkgs/top-level/php-packages.nix index 1f49a145c69..ff9e96f8b97 100644 --- a/pkgs/top-level/php-packages.nix +++ b/pkgs/top-level/php-packages.nix @@ -346,13 +346,6 @@ in version = "2.6.1"; pname = "couchbase"; - buildInputs = [ - pkgs.libcouchbase - pkgs.zlib - php.extensions.igbinary - php.extensions.pcs - ]; - src = pkgs.fetchFromGitHub { owner = "couchbase"; repo = "php-couchbase"; @@ -361,7 +354,14 @@ in }; configureFlags = [ "--with-couchbase" ]; + + buildInputs = [ + pkgs.libcouchbase + pkgs.zlib + ]; internalDeps = [ php.extensions.json ]; + peclDeps = [ php.extensions.igbinary ]; + patches = [ (pkgs.writeText "php-couchbase.patch" '' --- a/config.m4 @@ -388,7 +388,6 @@ in ]; meta.maintainers = lib.teams.php.members; - meta.broken = isPhp74; # Build error }; event = buildPecl {