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:
talyz 2020-04-11 21:48:37 +02:00
parent c89243a03e
commit a463261415
No known key found for this signature in database
GPG key ID: 2DED2151F4671A2B
2 changed files with 45 additions and 39 deletions

View file

@ -148,15 +148,21 @@ let
generic' = { version, sha256, self, selfWithExtensions, ... }@args:
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 = self;
phpWithExtensions = selfWithExtensions;
});
buildEnv = { extensions ? (_: []), extraConfig ? "" }:
buildEnv = lib.makeOverridable (
{ extensions ? (_: []), extraConfig ? "", ... }@innerArgs:
let
filteredInnerArgs = builtins.removeAttrs innerArgs [ "extensions" "extraConfig" ];
allArgs = filteredArgs // filteredInnerArgs;
php = generic allArgs;
getExtName = ext: lib.removePrefix "php-" (builtins.parseDrvName ext.name).name;
enabledExtensions = extensions php-packages.extensions;
@ -205,7 +211,7 @@ let
wrapProgram $out/bin/php-fpm --set PHP_INI_SCAN_DIR $out/lib
fi
'';
};
});
withExtensions = extensions: buildEnv { inherit extensions; };
in

View file

@ -9494,7 +9494,7 @@ in
php73Extensions = recurseIntoAttrs php73.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;
}) php74 php73 php72 php74base php73base php72base;