mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 23:13:19 +00:00
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 (_: {
|
||||
passthru.buildEnv = { exts ? (_: []), extraConfig ? "" }: let
|
||||
extraInit = writeText "custom-php.ini" ''
|
||||
${extraConfig}
|
||||
${lib.concatMapStringsSep "\n" (ext: let
|
||||
extName = lib.removePrefix "php-" (builtins.parseDrvName ext.name).name;
|
||||
type = "${lib.optionalString (ext.zendExtension or false) "zend_"}extension";
|
||||
in ''
|
||||
${type}=${ext}/lib/php/extensions/${extName}.so
|
||||
'') (exts (callPackage ../../../top-level/php-packages.nix { inherit php; }))}
|
||||
'';
|
||||
in symlinkJoin {
|
||||
name = "php-custom-${version}";
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
paths = [ php ];
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/php \
|
||||
--add-flags "-c ${extraInit}"
|
||||
wrapProgram $out/bin/php-fpm \
|
||||
--add-flags "-c ${extraInit}"
|
||||
'';
|
||||
};
|
||||
});
|
||||
generic' = { version, sha256, ... }@args:
|
||||
let
|
||||
php = generic args;
|
||||
buildEnv = { exts ? (_: []), extraConfig ? "" }:
|
||||
let
|
||||
getExtName = ext: lib.removePrefix "php-" (builtins.parseDrvName ext.name).name;
|
||||
extList = exts (callPackage ../../../top-level/php-packages.nix { inherit php; });
|
||||
|
||||
# Generate extension load configuration snippets from
|
||||
# exts. 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;
|
||||
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' {
|
||||
version = "7.2.28";
|
||||
|
@ -717,7 +717,7 @@ let
|
||||
, doCheck ? true
|
||||
, ...
|
||||
}: stdenv.mkDerivation {
|
||||
pname = "php-ext-${name}";
|
||||
pname = "php-${name}";
|
||||
|
||||
inherit (php) version src;
|
||||
sourceRoot = "php-${php.version}/ext/${name}";
|
||||
@ -746,7 +746,7 @@ let
|
||||
checkPhase = "echo n | make test";
|
||||
installPhase = ''
|
||||
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
Block a user