Merge pull request #107044 from jtojnar/overridable-php-packages
This commit is contained in:
commit
3dfcc7e3a5
@ -135,3 +135,21 @@ Example of building `composer` with additional extensions:
|
|||||||
enabled ++ (with all; [ imagick redis ]))
|
enabled ++ (with all; [ imagick redis ]))
|
||||||
).packages.composer
|
).packages.composer
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Overriding PHP packages {#ssec-php-user-guide-overriding-packages}
|
||||||
|
|
||||||
|
`php-packages.nix` form a scope, allowing us to override the packages defined within. For example, to apply a patch to a `mysqlnd` extension, you can simply pass an overlay-style function to `php`’s `packageOverrides` argument:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
php.override {
|
||||||
|
packageOverrides = final: prev: {
|
||||||
|
extensions = prev.extensions // {
|
||||||
|
mysqlnd = prev.extensions.mysqlnd.overrideAttrs (attrs: {
|
||||||
|
patches = attrs.patches or [] ++ [
|
||||||
|
…
|
||||||
|
];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
@ -13,6 +13,7 @@ let
|
|||||||
, version
|
, version
|
||||||
, sha256
|
, sha256
|
||||||
, extraPatches ? []
|
, extraPatches ? []
|
||||||
|
, packageOverrides ? (final: prev: {})
|
||||||
|
|
||||||
# Sapi flags
|
# Sapi flags
|
||||||
, cgiSupport ? true
|
, cgiSupport ? true
|
||||||
@ -49,8 +50,8 @@ let
|
|||||||
php = generic filteredArgs;
|
php = generic filteredArgs;
|
||||||
|
|
||||||
php-packages = (callPackage ../../../top-level/php-packages.nix {
|
php-packages = (callPackage ../../../top-level/php-packages.nix {
|
||||||
php = phpWithExtensions;
|
phpPackage = phpWithExtensions;
|
||||||
});
|
}).overrideScope' packageOverrides;
|
||||||
|
|
||||||
allExtensionFunctions = prevExtensionFunctions ++ [ extensions ];
|
allExtensionFunctions = prevExtensionFunctions ++ [ extensions ];
|
||||||
enabledExtensions =
|
enabledExtensions =
|
||||||
@ -112,7 +113,8 @@ 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 buildPecl;
|
inherit (php-packages) extensions buildPecl;
|
||||||
|
packages = php-packages.tools;
|
||||||
meta = php.meta // {
|
meta = php.meta // {
|
||||||
outputsToInstall = [ "out" ];
|
outputsToInstall = [ "out" ];
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ stdenv, lib, pkgs, fetchgit, php, autoconf, pkgconfig, re2c
|
{ stdenv, lib, pkgs, fetchgit, phpPackage, autoconf, pkgconfig, re2c
|
||||||
, gettext, bzip2, curl, libxml2, openssl, gmp, icu64, oniguruma, libsodium
|
, gettext, bzip2, curl, libxml2, openssl, gmp, icu64, oniguruma, libsodium
|
||||||
, html-tidy, libzip, zlib, pcre, pcre2, libxslt, aspell, openldap, cyrus_sasl
|
, html-tidy, libzip, zlib, pcre, pcre2, libxslt, aspell, openldap, cyrus_sasl
|
||||||
, uwimap, pam, libiconv, enchant1, libXpm, gd, libwebp, libjpeg, libpng
|
, uwimap, pam, libiconv, enchant1, libXpm, gd, libwebp, libjpeg, libpng
|
||||||
@ -6,7 +6,7 @@
|
|||||||
, readline, rsync, fetchpatch, valgrind
|
, readline, rsync, fetchpatch, valgrind
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
lib.makeScope pkgs.newScope (self: with self; {
|
||||||
buildPecl = import ../build-support/build-pecl.nix {
|
buildPecl = import ../build-support/build-pecl.nix {
|
||||||
php = php.unwrapped;
|
php = php.unwrapped;
|
||||||
inherit lib;
|
inherit lib;
|
||||||
@ -21,15 +21,10 @@ let
|
|||||||
|
|
||||||
pcre' = if (lib.versionAtLeast php.version "7.3") then pcre2 else pcre;
|
pcre' = if (lib.versionAtLeast php.version "7.3") then pcre2 else pcre;
|
||||||
|
|
||||||
callPackage = pkgs.newScope {
|
php = phpPackage;
|
||||||
inherit mkDerivation php buildPecl pcre';
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit buildPecl;
|
|
||||||
|
|
||||||
# This is a set of interactive tools based on PHP.
|
# This is a set of interactive tools based on PHP.
|
||||||
packages = {
|
tools = {
|
||||||
box = callPackage ../development/php-packages/box { };
|
box = callPackage ../development/php-packages/box { };
|
||||||
|
|
||||||
composer = callPackage ../development/php-packages/composer { };
|
composer = callPackage ../development/php-packages/composer { };
|
||||||
@ -550,4 +545,4 @@ in
|
|||||||
|
|
||||||
# Produce the final attribute set of all extensions defined.
|
# Produce the final attribute set of all extensions defined.
|
||||||
in builtins.listToAttrs namedExtensions);
|
in builtins.listToAttrs namedExtensions);
|
||||||
}
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user