php: Make buildEnv recursive + take extension deps into account
A slight rewrite of buildEnv which: 1. Makes buildEnv recursively add itself to its output, so that it can be accessed from any php derivation. 2. Orders the extension text strings according to their internalDeps attribute - dependencies have to be put before dependants in the php.ini or they will fail to load due to missing symbols.
This commit is contained in:
parent
6c810c235d
commit
8924a7de3d
|
@ -144,29 +144,57 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
generic' = { version, sha256, ... }@args: let php = generic args; in php.overrideAttrs (_: {
|
generic' = { version, sha256, ... }@args:
|
||||||
passthru.buildEnv = { exts ? (_: []), extraConfig ? "" }: let
|
let
|
||||||
extraInit = writeText "custom-php.ini" ''
|
php = generic args;
|
||||||
${extraConfig}
|
buildEnv = { exts ? (_: []), extraConfig ? "" }:
|
||||||
${lib.concatMapStringsSep "\n" (ext: let
|
let
|
||||||
extName = lib.removePrefix "php-" (builtins.parseDrvName ext.name).name;
|
getExtName = ext: lib.removePrefix "php-" (builtins.parseDrvName ext.name).name;
|
||||||
type = "${lib.optionalString (ext.zendExtension or false) "zend_"}extension";
|
extList = exts (callPackage ../../../top-level/php-packages.nix { inherit php; });
|
||||||
in ''
|
|
||||||
${type}=${ext}/lib/php/extensions/${extName}.so
|
# Generate extension load configuration snippets from
|
||||||
'') (exts (callPackage ../../../top-level/php-packages.nix { inherit php; }))}
|
# exts. This is an attrset suitable for use with
|
||||||
'';
|
# textClosureList, which is used to put the strings in the
|
||||||
in symlinkJoin {
|
# right order - if a plugin which is dependent on another
|
||||||
name = "php-custom-${version}";
|
# plugin is placed before its dependency, it will fail to
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
# load.
|
||||||
paths = [ php ];
|
extensionTexts =
|
||||||
postBuild = ''
|
lib.listToAttrs
|
||||||
wrapProgram $out/bin/php \
|
(map (ext:
|
||||||
--add-flags "-c ${extraInit}"
|
let
|
||||||
wrapProgram $out/bin/php-fpm \
|
extName = getExtName ext;
|
||||||
--add-flags "-c ${extraInit}"
|
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) ext.internalDeps;
|
||||||
|
})
|
||||||
|
extList);
|
||||||
|
|
||||||
|
extNames = map getExtName extList;
|
||||||
|
extraInit = writeText "custom-php.ini" ''
|
||||||
|
${extraConfig}
|
||||||
|
${lib.concatStringsSep "\n"
|
||||||
|
(lib.textClosureList extensionTexts extNames)}
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
symlinkJoin {
|
||||||
|
name = "php-with-extensions-${version}";
|
||||||
|
inherit version;
|
||||||
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
|
passthru.buildEnv = buildEnv;
|
||||||
|
paths = [ php ];
|
||||||
|
postBuild = ''
|
||||||
|
wrapProgram $out/bin/php \
|
||||||
|
--add-flags "-c ${extraInit}"
|
||||||
|
wrapProgram $out/bin/php-fpm \
|
||||||
|
--add-flags "-c ${extraInit}"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
|
php.overrideAttrs (_: {
|
||||||
|
passthru.buildEnv = buildEnv;
|
||||||
|
});
|
||||||
|
|
||||||
php72base = generic' {
|
php72base = generic' {
|
||||||
version = "7.2.28";
|
version = "7.2.28";
|
||||||
|
|
|
@ -717,7 +717,7 @@ let
|
||||||
, doCheck ? true
|
, doCheck ? true
|
||||||
, ...
|
, ...
|
||||||
}: stdenv.mkDerivation {
|
}: stdenv.mkDerivation {
|
||||||
pname = "php-ext-${name}";
|
pname = "php-${name}";
|
||||||
|
|
||||||
inherit (php) version src;
|
inherit (php) version src;
|
||||||
sourceRoot = "php-${php.version}/ext/${name}";
|
sourceRoot = "php-${php.version}/ext/${name}";
|
||||||
|
@ -746,7 +746,7 @@ let
|
||||||
checkPhase = "echo n | make test";
|
checkPhase = "echo n | make test";
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/lib/php/extensions
|
mkdir -p $out/lib/php/extensions
|
||||||
cp modules/${name}.so $out/lib/php/extensions/ext-${name}.so
|
cp modules/${name}.so $out/lib/php/extensions/${name}.so
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue