php.buildEnv: Make the exported php package overridable
This implements the override pattern for builds done with buildEnv, so that we can, for example, write php.override { fpmSupport = false; } and get a PHP package with the default extensions enabled, but PHP compiled without fpm support.
This commit is contained in:
parent
c89243a03e
commit
a463261415
2 changed files with 45 additions and 39 deletions
|
@ -148,55 +148,61 @@ let
|
||||||
|
|
||||||
generic' = { version, sha256, self, selfWithExtensions, ... }@args:
|
generic' = { version, sha256, self, selfWithExtensions, ... }@args:
|
||||||
let
|
let
|
||||||
php = generic (builtins.removeAttrs args [ "self" "selfWithExtensions" ]);
|
filteredArgs = builtins.removeAttrs args [ "self" "selfWithExtensions" ];
|
||||||
|
php = generic filteredArgs;
|
||||||
|
|
||||||
php-packages = (callPackage ../../../top-level/php-packages.nix {
|
php-packages = (callPackage ../../../top-level/php-packages.nix {
|
||||||
php = self;
|
php = self;
|
||||||
phpWithExtensions = selfWithExtensions;
|
phpWithExtensions = selfWithExtensions;
|
||||||
});
|
});
|
||||||
|
|
||||||
buildEnv = { extensions ? (_: []), extraConfig ? "" }:
|
buildEnv = lib.makeOverridable (
|
||||||
let
|
{ extensions ? (_: []), extraConfig ? "", ... }@innerArgs:
|
||||||
getExtName = ext: lib.removePrefix "php-" (builtins.parseDrvName ext.name).name;
|
let
|
||||||
enabledExtensions = extensions php-packages.extensions;
|
filteredInnerArgs = builtins.removeAttrs innerArgs [ "extensions" "extraConfig" ];
|
||||||
|
allArgs = filteredArgs // filteredInnerArgs;
|
||||||
|
php = generic allArgs;
|
||||||
|
|
||||||
# Generate extension load configuration snippets from the
|
getExtName = ext: lib.removePrefix "php-" (builtins.parseDrvName ext.name).name;
|
||||||
# extension parameter. This is an attrset suitable for use
|
enabledExtensions = extensions php-packages.extensions;
|
||||||
# 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)
|
|
||||||
(map getExtName ext.internalDeps);
|
|
||||||
})
|
|
||||||
enabledExtensions);
|
|
||||||
|
|
||||||
extNames = map getExtName enabledExtensions;
|
# Generate extension load configuration snippets from the
|
||||||
extraInit = writeText "custom-php.ini" ''
|
# extension parameter. 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)
|
||||||
|
(map getExtName ext.internalDeps);
|
||||||
|
})
|
||||||
|
enabledExtensions);
|
||||||
|
|
||||||
|
extNames = map getExtName enabledExtensions;
|
||||||
|
extraInit = writeText "custom-php.ini" ''
|
||||||
${lib.concatStringsSep "\n"
|
${lib.concatStringsSep "\n"
|
||||||
(lib.textClosureList extensionTexts extNames)}
|
(lib.textClosureList extensionTexts extNames)}
|
||||||
${extraConfig}
|
${extraConfig}
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
symlinkJoin {
|
symlinkJoin {
|
||||||
name = "php-with-extensions-${version}";
|
name = "php-with-extensions-${version}";
|
||||||
inherit (php) version;
|
inherit (php) version;
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit buildEnv withExtensions enabledExtensions;
|
inherit buildEnv withExtensions enabledExtensions;
|
||||||
inherit (php-packages) packages extensions;
|
inherit (php-packages) packages extensions;
|
||||||
};
|
};
|
||||||
paths = [ php ];
|
paths = [ php ];
|
||||||
postBuild = ''
|
postBuild = ''
|
||||||
cp ${extraInit} $out/lib/custom-php.ini
|
cp ${extraInit} $out/lib/custom-php.ini
|
||||||
|
|
||||||
wrapProgram $out/bin/php --set PHP_INI_SCAN_DIR $out/lib
|
wrapProgram $out/bin/php --set PHP_INI_SCAN_DIR $out/lib
|
||||||
|
@ -205,7 +211,7 @@ let
|
||||||
wrapProgram $out/bin/php-fpm --set PHP_INI_SCAN_DIR $out/lib
|
wrapProgram $out/bin/php-fpm --set PHP_INI_SCAN_DIR $out/lib
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
});
|
||||||
|
|
||||||
withExtensions = extensions: buildEnv { inherit extensions; };
|
withExtensions = extensions: buildEnv { inherit extensions; };
|
||||||
in
|
in
|
||||||
|
|
|
@ -9494,7 +9494,7 @@ in
|
||||||
php73Extensions = recurseIntoAttrs php73.extensions;
|
php73Extensions = recurseIntoAttrs php73.extensions;
|
||||||
php74Extensions = recurseIntoAttrs php74.extensions;
|
php74Extensions = recurseIntoAttrs php74.extensions;
|
||||||
|
|
||||||
inherit (callPackages ../development/interpreters/php {
|
inherit (callPackage ../development/interpreters/php {
|
||||||
stdenv = if stdenv.cc.isClang then llvmPackages_6.stdenv else stdenv;
|
stdenv = if stdenv.cc.isClang then llvmPackages_6.stdenv else stdenv;
|
||||||
}) php74 php73 php72 php74base php73base php72base;
|
}) php74 php73 php72 php74base php73base php72base;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue