From 2ba79269590cd186c3ad6e5226c4322de8984d87 Mon Sep 17 00:00:00 2001 From: talyz Date: Sun, 12 Apr 2020 23:31:56 +0200 Subject: php.buildEnv: Provide a list of currently enabled extensions Rework withExtensions / buildEnv to handle currently enabled extensions better and make them compatible with override. They now accept a function with the named arguments enabled and all, where enabled is a list of currently enabled extensions and all is the set of all extensions. This gives us several nice properties: - You always get the right version of the list of currently enabled extensions - Invocations chain - It works well with overridden PHP packages - you always get the correct versions of extensions As a contrived example of what's possible, you can add ImageMagick, then override the version and disable fpm, then disable cgi, and lastly remove the zip extension like this: { pkgs ? (import ) {} }: with pkgs; let phpWithImagick = php74.withExtensions ({ all, enabled }: enabled ++ [ all.imagick ]); phpWithImagickWithoutFpm743 = phpWithImagick.override { version = "7.4.3"; sha256 = "wVF7pJV4+y3MZMc6Ptx21PxQfEp6xjmYFYTMfTtMbRQ="; fpmSupport = false; }; phpWithImagickWithoutFpmZip743 = phpWithImagickWithoutFpm743.withExtensions ( { enabled, all }: lib.filter (e: e != all.zip) enabled); phpWithImagickWithoutFpmZipCgi743 = phpWithImagickWithoutFpmZip743.override { cgiSupport = false; }; in phpWithImagickWithoutFpmZipCgi743 --- nixos/doc/manual/release-notes/rl-2009.xml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'nixos/doc/manual') diff --git a/nixos/doc/manual/release-notes/rl-2009.xml b/nixos/doc/manual/release-notes/rl-2009.xml index 3e29c19af8fb..e4e44c8405f3 100644 --- a/nixos/doc/manual/release-notes/rl-2009.xml +++ b/nixos/doc/manual/release-notes/rl-2009.xml @@ -135,18 +135,23 @@ - Since this release there's an easy way to customize your PHP install to get a much smaller - base PHP with only wanted extensions enabled. See the following snippet installing a smaller PHP - with the extensions imagick, opcache and + Since this release there's an easy way to customize your PHP + install to get a much smaller base PHP with only wanted + extensions enabled. See the following snippet installing a + smaller PHP with the extensions imagick, + opcache, pdo and pdo_mysql loaded: environment.systemPackages = [ -(pkgs.php.buildEnv { extensions = pp: with pp; [ - imagick - opcache - pdo_mysql - ]; }) + (pkgs.php.withExtensions + ({ all, ... }: with all; [ + imagick + opcache + pdo + pdo_mysql + ]) + ) ]; The default php attribute hasn't lost any extensions - -- cgit 1.4.1 From 72636bc2f6321e5e25414904685ba9fbabbbfb56 Mon Sep 17 00:00:00 2001 From: talyz Date: Fri, 24 Apr 2020 13:29:46 +0200 Subject: php: Get rid of all config.php parameters Since all options controlled by the config.php parameters can now be overridden directly, there's no reason to keep them around. --- nixos/doc/manual/release-notes/rl-2009.xml | 79 +++++++++++++-------------- pkgs/development/interpreters/php/default.nix | 29 +++++----- pkgs/servers/http/unit/default.nix | 12 ++-- pkgs/servers/uwsgi/default.nix | 4 +- pkgs/top-level/aliases.nix | 48 ++++++++-------- 5 files changed, 84 insertions(+), 88 deletions(-) (limited to 'nixos/doc/manual') diff --git a/nixos/doc/manual/release-notes/rl-2009.xml b/nixos/doc/manual/release-notes/rl-2009.xml index e4e44c8405f3..8231bf9842f1 100644 --- a/nixos/doc/manual/release-notes/rl-2009.xml +++ b/nixos/doc/manual/release-notes/rl-2009.xml @@ -154,55 +154,50 @@ environment.systemPackages = [ ) ]; - The default php attribute hasn't lost any extensions - - the opcache extension was added there. + The default php attribute hasn't lost any + extensions. The opcache extension has been + added. All upstream PHP extensions are available under ]]>. - The updated php attribute is now easily customizable to your liking - by using extensions instead of writing config files or changing configure flags. - - Therefore we have removed the following configure flags: + All PHP config flags have been removed for + the following reasons: - PHP <literal>config</literal> flags that we don't read anymore: - config.php.argon2 - config.php.bcmath - config.php.bz2 - config.php.calendar - config.php.curl - config.php.exif - config.php.ftp - config.php.gd - config.php.gettext - config.php.gmp - config.php.imap - config.php.intl - config.php.ldap - config.php.libxml2 - config.php.libzip - config.php.mbstring - config.php.mysqli - config.php.mysqlnd - config.php.openssl - config.php.pcntl - config.php.pdo_mysql - config.php.pdo_odbc - config.php.pdo_pgsql - config.php.phpdbg - config.php.postgresql - config.php.readline - config.php.soap - config.php.sockets - config.php.sodium - config.php.sqlite - config.php.tidy - config.php.xmlrpc - config.php.xsl - config.php.zip - config.php.zlib + + + The updated php attribute is now easily + customizable to your liking by using + php.withExtensions or + php.buildEnv instead of writing config files + or changing configure flags. + + + + + The remaining configuration flags can now be set directly on + the php attribute. For example, instead of + + +php.override { + config.php.embed = true; + config.php.apxs2 = false; +} + + + you should now write + + +php.override { + embedSupport = true; + apxs2Support = false; +} + + + + diff --git a/pkgs/development/interpreters/php/default.nix b/pkgs/development/interpreters/php/default.nix index 2313f9fbcc48..33071b06d956 100644 --- a/pkgs/development/interpreters/php/default.nix +++ b/pkgs/development/interpreters/php/default.nix @@ -17,23 +17,22 @@ let , defaultPhpExtensions # Sapi flags - , cgiSupport ? config.php.cgi or true - , cliSupport ? config.php.cli or true - , fpmSupport ? config.php.fpm or true - , pearSupport ? config.php.pear or true - , pharSupport ? config.php.phar or true - , phpdbgSupport ? config.php.phpdbg or true - + , cgiSupport ? true + , cliSupport ? true + , fpmSupport ? true + , pearSupport ? true + , pharSupport ? true + , phpdbgSupport ? true # Misc flags - , apxs2Support ? config.php.apxs2 or (!stdenv.isDarwin) - , argon2Support ? config.php.argon2 or true - , cgotoSupport ? config.php.cgoto or false - , embedSupport ? config.php.embed or false - , ipv6Support ? config.php.ipv6 or true - , systemdSupport ? config.php.systemd or stdenv.isLinux - , valgrindSupport ? config.php.valgrind or true - , ztsSupport ? (config.php.zts or false) || (apxs2Support) + , apxs2Support ? !stdenv.isDarwin + , argon2Support ? true + , cgotoSupport ? false + , embedSupport ? false + , ipv6Support ? true + , systemdSupport ? stdenv.isLinux + , valgrindSupport ? true + , ztsSupport ? apxs2Support }@args: let self = generic args; diff --git a/pkgs/servers/http/unit/default.nix b/pkgs/servers/http/unit/default.nix index 1e3ddb4ad8f1..f8992bf166b3 100644 --- a/pkgs/servers/http/unit/default.nix +++ b/pkgs/servers/http/unit/default.nix @@ -18,12 +18,12 @@ with stdenv.lib; let phpConfig = { - config.php.embed = true; - config.php.apxs2 = false; - config.php.systemd = false; - config.php.phpdbg = false; - config.php.cgi = false; - config.php.fpm = false; + embedSupport = true; + apxs2Support = false; + systemdSupport = false; + phpdbgSupport = false; + cgiSupport = false; + fpmSupport = false; }; php72-unit = php72base.override phpConfig; diff --git a/pkgs/servers/uwsgi/default.nix b/pkgs/servers/uwsgi/default.nix index 29b807f17920..0f0d2c23e4c4 100644 --- a/pkgs/servers/uwsgi/default.nix +++ b/pkgs/servers/uwsgi/default.nix @@ -8,8 +8,8 @@ }: let php-embed = php.override { - config.php.embed = true; - config.php.apxs2 = false; + embedSupport = true; + apxs2Support = false; }; pythonPlugin = pkg : lib.nameValuePair "python${if pkg.isPy2 then "2" else "3"}" { diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 9ad282149aa6..678cb0d983a6 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -332,48 +332,50 @@ mapAliases ({ pg_tmp = ephemeralpg; # added 2018-01-16 php-embed = throw '' - php*-embed has been dropped, you can build the same package by using - something similar with this following snippet: - (php74.override { config.php.embed = true; config.php.apxs2 = false; }) + php*-embed has been dropped, you can build something similar + with the following snippet: + php74.override { embedSupport = true; apxs2Support = false; } ''; # added 2020-04-01 php72-embed = php-embed; # added 2020-04-01 php73-embed = php-embed; # added 2020-04-01 php74-embed = php-embed; # added 2020-04-01 phpPackages-embed = throw '' - php*Packages-embed has been dropped, you can build the same package by using - something similar with this following snippet: - (php74.override { config.php.embed = true; config.php.apxs2 = false; }).packages + php*Packages-embed has been dropped, you can build something + similar with the following snippet: + (php74.override { embedSupport = true; apxs2Support = false; }).packages ''; # added 2020-04-01 php74Packages-embed = phpPackages-embed; php73Packages-embed = phpPackages-embed; php72Packages-embed = phpPackages-embed; php-unit = throw '' - php*-unit has been dropped, you can build the same package by using - something similar with this following snippet: - (php74.override { - config.php.embed = true; - config.php.apxs2 = false; - config.php.systemd = false; - config.php.phpdbg = false; - config.php.cgi = false; - config.php.fpm = false; }) + php*-unit has been dropped, you can build something similar with + the following snippet: + php74.override { + embedSupport = true; + apxs2Support = false; + systemdSupport = false; + phpdbgSupport = false; + cgiSupport = false; + fpmSupport = false; + } ''; # added 2020-04-01 php72-unit = php-unit; # added 2020-04-01 php73-unit = php-unit; # added 2020-04-01 php74-unit = php-unit; # added 2020-04-01 phpPackages-unit = throw '' - php*Packages-unit has been dropped, you can build the same package by using - something similar with this following snippet: + php*Packages-unit has been dropped, you can build something + similar with this following snippet: (php74.override { - config.php.embed = true; - config.php.apxs2 = false; - config.php.systemd = false; - config.php.phpdbg = false; - config.php.cgi = false; - config.php.fpm = false; }).packages + embedSupport = true; + apxs2Support = false; + systemdSupport = false; + phpdbgSupport = false; + cgiSupport = false; + fpmSupport = false; + }).packages ''; # added 2020-04-01 php74Packages-unit = phpPackages-unit; php73Packages-unit = phpPackages-unit; -- cgit 1.4.1