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.
This commit is contained in:
talyz 2020-05-02 23:13:53 +02:00
parent d373d80b12
commit 9f09253e52
No known key found for this signature in database
GPG key ID: 2DED2151F4671A2B
2 changed files with 7 additions and 5 deletions

View file

@ -3,6 +3,7 @@
{ pname { pname
, version , version
, internalDeps ? [] , internalDeps ? []
, peclDeps ? []
, buildInputs ? [] , buildInputs ? []
, nativeBuildInputs ? [] , nativeBuildInputs ? []
, postPhpize ? "" , postPhpize ? ""
@ -16,11 +17,12 @@
stdenv.mkDerivation (args // { stdenv.mkDerivation (args // {
name = "php-${pname}-${version}"; name = "php-${pname}-${version}";
extensionName = pname;
inherit src; inherit src;
nativeBuildInputs = [ autoreconfHook re2c ] ++ nativeBuildInputs; nativeBuildInputs = [ autoreconfHook re2c ] ++ nativeBuildInputs;
buildInputs = [ php ] ++ buildInputs; buildInputs = [ php ] ++ peclDeps ++ buildInputs;
makeFlags = [ "EXTENSION_DIR=$(out)/lib/php/extensions" ] ++ makeFlags; makeFlags = [ "EXTENSION_DIR=$(out)/lib/php/extensions" ] ++ makeFlags;

View file

@ -67,7 +67,7 @@ let
getDepsRecursively = extensions: getDepsRecursively = extensions:
let let
deps = lib.concatMap deps = lib.concatMap
(ext: ext.internalDeps or []) (ext: (ext.internalDeps or []) ++ (ext.peclDeps or []))
extensions; extensions;
in in
if ! (deps == []) then if ! (deps == []) then
@ -86,12 +86,12 @@ let
(map (ext: (map (ext:
let let
extName = getExtName ext; extName = getExtName ext;
phpDeps = (ext.internalDeps or []) ++ (ext.peclDeps or []);
type = "${lib.optionalString (ext.zendExtension or false) "zend_"}extension"; type = "${lib.optionalString (ext.zendExtension or false) "zend_"}extension";
in in
lib.nameValuePair extName { lib.nameValuePair extName {
text = "${type}=${ext}/lib/php/extensions/${extName}.so"; text = "${type}=${ext}/lib/php/extensions/${extName}.so";
deps = lib.optionals (ext ? internalDeps) deps = map getExtName phpDeps;
(map getExtName ext.internalDeps);
}) })
(enabledExtensions ++ (getDepsRecursively enabledExtensions))); (enabledExtensions ++ (getDepsRecursively enabledExtensions)));
@ -112,7 +112,7 @@ let
phpIni = "${phpWithExtensions}/lib/php.ini"; phpIni = "${phpWithExtensions}/lib/php.ini";
unwrapped = php; unwrapped = php;
tests = nixosTests.php; tests = nixosTests.php;
inherit (php-packages) packages extensions; inherit (php-packages) packages extensions buildPecl;
meta = php.meta // { meta = php.meta // {
outputsToInstall = [ "out" ]; outputsToInstall = [ "out" ];
}; };