php: split php.packages to php.packages and php.extensions

So now we have only packages for human interaction in php.packages and
only extensions in php.extensions. With this php.packages.exts have
been merged into the same attribute set as all the other extensions to
make it flat and nice.

The nextcloud module have been updated to reflect this change as well
as the documentation.
This commit is contained in:
Elis Hirwing 2020-04-02 22:13:04 +02:00 committed by talyz
parent a4bc30c802
commit a2099156ec
No known key found for this signature in database
GPG key ID: 2DED2151F4671A2B
6 changed files with 613 additions and 603 deletions

View file

@ -21,20 +21,12 @@ of a given NixOS release will be included in that release of
NixOS. See [PHP Supported NixOS. See [PHP Supported
Versions](https://www.php.net/supported-versions.php). Versions](https://www.php.net/supported-versions.php).
As for packages we have `php.packages` that contains a bunch of For packages we have `php.packages` that contains packages related
attributes where some are suitable as extensions (notable example: for human interaction, notable example is `php.packages.composer`.
`php.packages.imagick`). And some are more suitable for command
line use (notable example: `php.packages.composer`).
We have a special section within `php.packages` called For extensions we have `php.extensions` that contains most upstream
`php.packages.exts` that contain certain PHP modules that may not extensions as separate attributes as well some additional extensions
be part of the default PHP derivation (example: that tend to be popular, notable example is: `php.extensions.imagick`.
`php.packages.exts.opcache`).
The `php.packages.exts.*` attributes are official extensions which
originate from the mainline PHP project, while other extensions within
the `php.packages.*` attribute are of mixed origin (such as `pecl`
and other places).
The different versions of PHP that nixpkgs fetch is located under The different versions of PHP that nixpkgs fetch is located under
attributes named based on major and minor version number; e.g., attributes named based on major and minor version number; e.g.,
@ -43,23 +35,20 @@ attributes named based on major and minor version number; e.g.,
#### Installing PHP with packages #### Installing PHP with packages
There's two different kinds of things you could install: There's two majorly different parts of the PHP ecosystem in NixOS:
- A command line utility. Simply refer to it via - Command line utilities for human interaction. These comes from the
`php*.packages.*`, and it automatically comes with the necessary `php.packages.*` attributes.
PHP environment, certain extensions and libraries around it. - PHP environments with different extensions enabled. These are
- A PHP interpreter with certain extensions available. The `php` composed with `php.buildEnv` using an additional configuration file.
attribute provides `php.buildEnv` that allows you to wrap the PHP
derivation with an additional config file that makes PHP import
additional libraries or dependencies.
##### Example setup for `phpfpm` ##### Example setup for `phpfpm`
Example to build a PHP with `imagick` and `opcache` enabled, and Example to build a PHP with the extensions `imagick` and `opcache`
configure it for the "foo" `phpfpm` pool: enabled. Then to configure it for the "foo" `phpfpm` pool:
```nix ```nix
let let
myPhp = php.buildEnv { exts = pp: with pp; [ imagick exts.opcache ]; }; myPhp = php.buildEnv { exts = pp: with pp; [ imagick opcache ]; };
in { in {
services.phpfpm.pools."foo".phpPackage = myPhp; services.phpfpm.pools."foo".phpPackage = myPhp;
}; };
@ -68,8 +57,8 @@ in {
##### Example usage with `nix-shell` ##### Example usage with `nix-shell`
This brings up a temporary environment that contains a PHP interpreter This brings up a temporary environment that contains a PHP interpreter
with `imagick` and `opcache` enabled. with the extensions `imagick` and `opcache` enabled.
```sh ```sh
nix-shell -p 'php.buildEnv { exts = pp: with pp; [ imagick exts.opcache ]; }' nix-shell -p 'php.buildEnv { exts = pp: with pp; [ imagick opcache ]; }'
``` ```

View file

@ -134,8 +134,8 @@
<programlisting> <programlisting>
environment.systemPackages = [ environment.systemPackages = [
(pkgs.php.buildEnv { exts = pp: with pp.exts; [ (pkgs.php.buildEnv { exts = pp: with pp; [
pp.imagick imagick
opcache opcache
pdo_mysql pdo_mysql
]; }) ]; })
@ -144,7 +144,7 @@ environment.systemPackages = [
The default <literal>php</literal> attribute hasn't lost any extensions - The default <literal>php</literal> attribute hasn't lost any extensions -
the <literal>opcache</literal> extension was added there. the <literal>opcache</literal> extension was added there.
All upstream PHP extensions are available under <package><![CDATA[php.packages.exts.<name?>]]></package>. All upstream PHP extensions are available under <package><![CDATA[php.extensions.<name?>]]></package>.
</para> </para>
<para> <para>
The updated <literal>php</literal> attribute is now easily customizable to your liking The updated <literal>php</literal> attribute is now easily customizable to your liking

View file

@ -7,12 +7,12 @@ let
fpm = config.services.phpfpm.pools.nextcloud; fpm = config.services.phpfpm.pools.nextcloud;
phpPackage = pkgs.php74.buildEnv { phpPackage = pkgs.php74.buildEnv {
exts = pp: with pp.exts; [ exts = pp: with pp; [
bcmath calendar curl exif ftp filter gd gettext gmp intl json ldap bcmath calendar curl exif ftp filter gd gettext gmp intl json ldap
mysqlnd opcache openssl pcntl pdo pdo_mysql pdo_odbc pdo_pgsql mysqlnd opcache openssl pcntl pdo pdo_mysql pdo_odbc pdo_pgsql
pdo_sqlite pgsql readline session soap sodium sqlite3 zip zlib mbstring pdo_sqlite pgsql readline session soap sodium sqlite3 zip zlib mbstring
posix ctype dom simplexml xmlreader xmlwriter pp.apcu posix ctype dom simplexml xmlreader xmlwriter
pp.redis pp.memcached pp.imagick apcu redis memcached imagick
]; ];
extraConfig = phpOptionsStr; extraConfig = phpOptionsStr;
}; };

View file

@ -149,14 +149,21 @@ let
generic' = { version, sha256, self, selfWithExtensions, ... }@args: generic' = { version, sha256, self, selfWithExtensions, ... }@args:
let let
php = generic (builtins.removeAttrs args [ "self" "selfWithExtensions" ]); php = generic (builtins.removeAttrs args [ "self" "selfWithExtensions" ]);
packages = callPackage ../../../top-level/php-packages.nix {
packages = (callPackage ../../../top-level/php-packages.nix {
php = self; php = self;
phpWithExtensions = selfWithExtensions; phpWithExtensions = selfWithExtensions;
}; }).packages;
extensions = (callPackage ../../../top-level/php-packages.nix {
php = self;
phpWithExtensions = selfWithExtensions;
}).extensions;
buildEnv = { exts ? (_: []), extraConfig ? "" }: buildEnv = { exts ? (_: []), extraConfig ? "" }:
let let
getExtName = ext: lib.removePrefix "php-" (builtins.parseDrvName ext.name).name; getExtName = ext: lib.removePrefix "php-" (builtins.parseDrvName ext.name).name;
extList = exts packages; extList = exts extensions;
# Generate extension load configuration snippets from # Generate extension load configuration snippets from
# exts. This is an attrset suitable for use with # exts. This is an attrset suitable for use with
@ -190,7 +197,7 @@ let
inherit version; inherit version;
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [ makeWrapper ];
passthru = { passthru = {
inherit buildEnv packages; inherit buildEnv packages extensions;
}; };
paths = [ php ]; paths = [ php ];
postBuild = '' postBuild = ''
@ -206,7 +213,7 @@ let
in in
php.overrideAttrs (_: { php.overrideAttrs (_: {
passthru = { passthru = {
inherit buildEnv packages; inherit buildEnv packages extensions;
}; };
}); });
@ -238,7 +245,7 @@ let
}; };
defaultPhpExtensions = { defaultPhpExtensions = {
exts = pp: with pp.exts; ([ exts = pp: with pp; ([
bcmath calendar curl ctype dom exif fileinfo filter ftp gd bcmath calendar curl ctype dom exif fileinfo filter ftp gd
gettext gmp iconv intl json ldap mbstring mysqli mysqlnd opcache gettext gmp iconv intl json ldap mbstring mysqli mysqlnd opcache
openssl pcntl pdo pdo_mysql pdo_odbc pdo_pgsql pdo_sqlite pgsql openssl pcntl pdo pdo_mysql pdo_odbc pdo_pgsql pdo_sqlite pgsql

View file

@ -9377,6 +9377,11 @@ in
php73Packages = recurseIntoAttrs php73.packages; php73Packages = recurseIntoAttrs php73.packages;
php74Packages = recurseIntoAttrs php74.packages; php74Packages = recurseIntoAttrs php74.packages;
phpExtensions = php74Extensions;
php72Extensions = recurseIntoAttrs php72.extensions;
php73Extensions = recurseIntoAttrs php73.extensions;
php74Extensions = recurseIntoAttrs php74.extensions;
inherit (callPackages ../development/interpreters/php { inherit (callPackages ../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;

File diff suppressed because it is too large Load diff