Merge pull request #85026 from talyz/php_buildenv_override

php.buildEnv: Make the exported php package overridable, improve handling of currently enabled extensions, etc
This commit is contained in:
Elis Hirwing 2020-04-29 19:57:37 +02:00 committed by GitHub
commit 27b9b7b3af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 394 additions and 351 deletions

View file

@ -9,18 +9,24 @@
Several versions of PHP are available on Nix, each of which having a Several versions of PHP are available on Nix, each of which having a
wide variety of extensions and libraries available. wide variety of extensions and libraries available.
The attribute `php` refers to the version of PHP considered most The different versions of PHP that nixpkgs provides are located under
stable and thoroughly tested in nixpkgs for any given release of attributes named based on major and minor version number; e.g.,
NixOS. Note that while this version of PHP may not be the latest major `php74` is PHP 7.4.
release from upstream, any version of PHP supported in nixpkgs may be
utilized by specifying the desired attribute by version, such as
`php74`.
Only versions of PHP that are supported by upstream for the entirety Only versions of PHP that are supported by upstream for the entirety
of a given NixOS release will be included in that release of 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).
The attribute `php` refers to the version of PHP considered most
stable and thoroughly tested in nixpkgs for any given release of
NixOS - not necessarily the latest major release from upstream.
All available PHP attributes are wrappers around their respective
binary PHP package and provide commonly used extensions this way. The
real PHP 7.4 package, i.e. the unwrapped one, is available as
`php74.unwrapped`; see the next section for more details.
Interactive tools built on PHP are put in `php.packages`; composer is Interactive tools built on PHP are put in `php.packages`; composer is
for example available at `php.packages.composer`. for example available at `php.packages.composer`.
@ -30,39 +36,44 @@ opcache extension shipped with PHP is available at
`php.extensions.opcache` and the third-party ImageMagick extension at `php.extensions.opcache` and the third-party ImageMagick extension at
`php.extensions.imagick`. `php.extensions.imagick`.
The different versions of PHP that nixpkgs provides is located under #### Installing PHP with extensions
attributes named based on major and minor version number; e.g.,
`php74` is PHP 7.4 with commonly used extensions installed,
`php74base` is the same PHP runtime without extensions.
#### Installing PHP with packages
A PHP package with specific extensions enabled can be built using A PHP package with specific extensions enabled can be built using
`php.withExtensions`. This is a function which accepts an anonymous `php.withExtensions`. This is a function which accepts an anonymous
function as its only argument; the function should take one argument, function as its only argument; the function should accept two named
the set of all extensions, and return a list of wanted extensions. For parameters: `enabled` - a list of currently enabled extensions and
example, a PHP package with the opcache and ImageMagick extensions `all` - the set of all extensions, and return a list of wanted
enabled: extensions. For example, a PHP package with all default extensions and
ImageMagick enabled:
```nix ```nix
php.withExtensions (e: with e; [ imagick opcache ]) php.withExtensions ({ enabled, all }:
enabled ++ [ all.imagick ])
``` ```
Note that this will give you a package with _only_ opcache and To exclude some, but not all, of the default extensions, you can
ImageMagick, none of the other extensions which are enabled by default filter the `enabled` list like this:
in the `php` package will be available.
To enable building on a previous PHP package, the currently enabled
extensions are made available in its `enabledExtensions`
attribute. For example, to generate a package with all default
extensions enabled, except opcache, but with ImageMagick:
```nix ```nix
php.withExtensions (e: php.withExtensions ({ enabled, all }:
(lib.filter (e: e != php.extensions.opcache) php.enabledExtensions) (lib.filter (e: e != php.extensions.opcache) enabled)
++ [ e.imagick ]) ++ [ all.imagick ])
``` ```
To build your list of extensions from the ground up, you can simply
ignore `enabled`:
```nix
php.withExtensions ({ all, ... }: with all; [ opcache imagick ])
```
`php.withExtensions` provides extensions by wrapping a minimal php
base package, providing a `php.ini` file listing all extensions to be
loaded. You can access this package through the `php.unwrapped`
attribute; useful if you, for example, need access to the `dev`
output. The generated `php.ini` file can be accessed through the
`php.phpIni` attribute.
If you want a PHP build with extra configuration in the `php.ini` If you want a PHP build with extra configuration in the `php.ini`
file, you can use `php.buildEnv`. This function takes two named and file, you can use `php.buildEnv`. This function takes two named and
optional parameters: `extensions` and `extraConfig`. `extensions` optional parameters: `extensions` and `extraConfig`. `extensions`
@ -73,7 +84,7 @@ and ImageMagick extensions enabled, and `memory_limit` set to `256M`:
```nix ```nix
php.buildEnv { php.buildEnv {
extensions = e: with e; [ imagick opcache ]; extensions = { all, ... }: with all; [ imagick opcache ];
extraConfig = "memory_limit=256M"; extraConfig = "memory_limit=256M";
} }
``` ```
@ -85,7 +96,7 @@ follows:
```nix ```nix
let let
myPhp = php.withExtensions (e: with e; [ imagick opcache ]); myPhp = php.withExtensions ({ all, ... }: with all; [ opcache imagick ]);
in { in {
services.phpfpm.pools."foo".phpPackage = myPhp; services.phpfpm.pools."foo".phpPackage = myPhp;
}; };
@ -94,7 +105,7 @@ in {
```nix ```nix
let let
myPhp = php.buildEnv { myPhp = php.buildEnv {
extensions = e: with e; [ imagick opcache ]; extensions = { all, ... }: with all; [ imagick opcache ];
extraConfig = "memory_limit=256M"; extraConfig = "memory_limit=256M";
}; };
in { in {
@ -105,8 +116,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 the extensions `imagick` and `opcache` enabled. with the extensions `imagick` and `opcache` enabled:
```sh ```sh
nix-shell -p 'php.buildEnv { extensions = e: with e; [ imagick opcache ]; }' nix-shell -p 'php.withExtensions ({ all, ... }: with all; [ imagick opcache ])'
``` ```

View file

@ -145,69 +145,69 @@
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
Since this release there's an easy way to customize your PHP install to get a much smaller Since this release there's an easy way to customize your PHP
base PHP with only wanted extensions enabled. See the following snippet installing a smaller PHP install to get a much smaller base PHP with only wanted
with the extensions <literal>imagick</literal>, <literal>opcache</literal> and extensions enabled. See the following snippet installing a
smaller PHP with the extensions <literal>imagick</literal>,
<literal>opcache</literal>, <literal>pdo</literal> and
<literal>pdo_mysql</literal> loaded: <literal>pdo_mysql</literal> loaded:
<programlisting> <programlisting>
environment.systemPackages = [ environment.systemPackages = [
(pkgs.php.buildEnv { extensions = pp: with pp; [ (pkgs.php.withExtensions
({ all, ... }: with all; [
imagick imagick
opcache opcache
pdo
pdo_mysql pdo_mysql
]; }) ])
)
];</programlisting> ];</programlisting>
The default <literal>php</literal> attribute hasn't lost any extensions - The default <literal>php</literal> attribute hasn't lost any
the <literal>opcache</literal> extension was added there. extensions. The <literal>opcache</literal> extension has been
added.
All upstream PHP extensions are available under <package><![CDATA[php.extensions.<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 All PHP <literal>config</literal> flags have been removed for
by using extensions instead of writing config files or changing configure flags. the following reasons:
Therefore we have removed the following configure flags:
<itemizedlist> <itemizedlist>
<title>PHP <literal>config</literal> flags that we don't read anymore:</title> <listitem>
<listitem><para><literal>config.php.argon2</literal></para></listitem> <para>
<listitem><para><literal>config.php.bcmath</literal></para></listitem> The updated <literal>php</literal> attribute is now easily
<listitem><para><literal>config.php.bz2</literal></para></listitem> customizable to your liking by using
<listitem><para><literal>config.php.calendar</literal></para></listitem> <literal>php.withExtensions</literal> or
<listitem><para><literal>config.php.curl</literal></para></listitem> <literal>php.buildEnv</literal> instead of writing config files
<listitem><para><literal>config.php.exif</literal></para></listitem> or changing configure flags.
<listitem><para><literal>config.php.ftp</literal></para></listitem> </para>
<listitem><para><literal>config.php.gd</literal></para></listitem> </listitem>
<listitem><para><literal>config.php.gettext</literal></para></listitem> <listitem>
<listitem><para><literal>config.php.gmp</literal></para></listitem> <para>
<listitem><para><literal>config.php.imap</literal></para></listitem> The remaining configuration flags can now be set directly on
<listitem><para><literal>config.php.intl</literal></para></listitem> the <literal>php</literal> attribute. For example, instead of
<listitem><para><literal>config.php.ldap</literal></para></listitem>
<listitem><para><literal>config.php.libxml2</literal></para></listitem> <programlisting>
<listitem><para><literal>config.php.libzip</literal></para></listitem> php.override {
<listitem><para><literal>config.php.mbstring</literal></para></listitem> config.php.embed = true;
<listitem><para><literal>config.php.mysqli</literal></para></listitem> config.php.apxs2 = false;
<listitem><para><literal>config.php.mysqlnd</literal></para></listitem> }
<listitem><para><literal>config.php.openssl</literal></para></listitem> </programlisting>
<listitem><para><literal>config.php.pcntl</literal></para></listitem>
<listitem><para><literal>config.php.pdo_mysql</literal></para></listitem> you should now write
<listitem><para><literal>config.php.pdo_odbc</literal></para></listitem>
<listitem><para><literal>config.php.pdo_pgsql</literal></para></listitem> <programlisting>
<listitem><para><literal>config.php.phpdbg</literal></para></listitem> php.override {
<listitem><para><literal>config.php.postgresql</literal></para></listitem> embedSupport = true;
<listitem><para><literal>config.php.readline</literal></para></listitem> apxs2Support = false;
<listitem><para><literal>config.php.soap</literal></para></listitem> }
<listitem><para><literal>config.php.sockets</literal></para></listitem> </programlisting>
<listitem><para><literal>config.php.sodium</literal></para></listitem> </para>
<listitem><para><literal>config.php.sqlite</literal></para></listitem> </listitem>
<listitem><para><literal>config.php.tidy</literal></para></listitem>
<listitem><para><literal>config.php.xmlrpc</literal></para></listitem>
<listitem><para><literal>config.php.xsl</literal></para></listitem>
<listitem><para><literal>config.php.zip</literal></para></listitem>
<listitem><para><literal>config.php.zlib</literal></para></listitem>
</itemizedlist> </itemizedlist>
</para> </para>
</listitem> </listitem>
<listitem> <listitem>

View file

@ -7,7 +7,7 @@ let
fpm = config.services.phpfpm.pools.roundcube; fpm = config.services.phpfpm.pools.roundcube;
localDB = cfg.database.host == "localhost"; localDB = cfg.database.host == "localhost";
user = cfg.database.username; user = cfg.database.username;
phpWithPspell = pkgs.php.withExtensions (e: [ e.pspell ] ++ pkgs.php.enabledExtensions); phpWithPspell = pkgs.php.withExtensions ({ enabled, all }: [ all.pspell ] ++ enabled);
in in
{ {
options.services.roundcube = { options.services.roundcube = {

View file

@ -11,8 +11,8 @@ let
base = pkgs.php74; base = pkgs.php74;
in in
base.buildEnv { base.buildEnv {
extensions = e: with e; extensions = { enabled, all }: with all;
base.enabledExtensions ++ [ enabled ++ [
apcu redis memcached imagick apcu redis memcached imagick
]; ];
extraConfig = phpOptionsStr; extraConfig = phpOptionsStr;

View file

@ -338,7 +338,7 @@ let
} }
'' ''
cat ${php}/etc/php.ini > $out cat ${php}/etc/php.ini > $out
cat ${php}/lib/custom-php.ini > $out cat ${php.phpIni} > $out
echo "$options" >> $out echo "$options" >> $out
''; '';

View file

@ -1,38 +1,139 @@
# We have tests for PCRE and PHP-FPM in nixos/tests/php/ or # We have tests for PCRE and PHP-FPM in nixos/tests/php/ or
# both in the same attribute named nixosTests.php # both in the same attribute named nixosTests.php
{ callPackage, config, fetchurl, lib, makeWrapper, stdenv, symlinkJoin { callPackage, lib, stdenv, nixosTests }@_args:
, writeText , autoconf, automake, bison, flex, libtool, pkgconfig, re2c
, apacheHttpd, libargon2, libxml2, pcre, pcre2 , systemd, valgrind
}:
let let
generic = generic =
{ version { callPackage, lib, stdenv, nixosTests, config, fetchurl, makeWrapper
, symlinkJoin, writeText, autoconf, automake, bison, flex, libtool
, pkgconfig, re2c, apacheHttpd, libargon2, libxml2, pcre, pcre2
, systemd, valgrind
, version
, sha256 , sha256
, extraPatches ? [] , extraPatches ? []
# Sapi flags # Sapi flags
, cgiSupport ? config.php.cgi or true , cgiSupport ? true
, cliSupport ? config.php.cli or true , cliSupport ? true
, fpmSupport ? config.php.fpm or true , fpmSupport ? true
, pearSupport ? config.php.pear or true , pearSupport ? true
, pharSupport ? config.php.phar or true , pharSupport ? true
, phpdbgSupport ? config.php.phpdbg or true , phpdbgSupport ? true
# Misc flags # Misc flags
, apxs2Support ? config.php.apxs2 or (!stdenv.isDarwin) , apxs2Support ? !stdenv.isDarwin
, argon2Support ? config.php.argon2 or true , argon2Support ? true
, cgotoSupport ? config.php.cgoto or false , cgotoSupport ? false
, embedSupport ? config.php.embed or false , embedSupport ? false
, ipv6Support ? config.php.ipv6 or true , ipv6Support ? true
, systemdSupport ? config.php.systemd or stdenv.isLinux , systemdSupport ? stdenv.isLinux
, valgrindSupport ? config.php.valgrind or true , valgrindSupport ? true
, ztsSupport ? (config.php.zts or false) || (apxs2Support) , ztsSupport ? apxs2Support
}: let }@args:
let
# buildEnv wraps php to provide additional extensions and
# configuration. Its usage is documented in
# doc/languages-frameworks/php.section.md.
#
# Create a buildEnv with earlier overridden values and
# extensions functions in its closure. This is necessary for
# consecutive calls to buildEnv and overrides to work as
# expected.
mkBuildEnv = prevArgs: prevExtensionFunctions: lib.makeOverridable (
{ extensions ? ({...}: []), extraConfig ? "", ... }@innerArgs:
let
allArgs = args // prevArgs // innerArgs;
filteredArgs = builtins.removeAttrs allArgs [ "extensions" "extraConfig" ];
php = generic filteredArgs;
php-packages = (callPackage ../../../top-level/php-packages.nix {
php = phpWithExtensions;
});
allExtensionFunctions = prevExtensionFunctions ++ [ extensions ];
enabledExtensions =
builtins.foldl'
(state: f:
f { enabled = state; all = php-packages.extensions; })
[]
allExtensionFunctions;
getExtName = ext: lib.removePrefix "php-" (builtins.parseDrvName ext.name).name;
# Recursively get a list of all internal dependencies
# for a list of extensions.
getDepsRecursively = extensions:
let
deps = lib.concatMap
(ext: ext.internalDeps or [])
extensions;
in
if ! (deps == []) then
deps ++ (getDepsRecursively deps)
else
deps;
# Generate extension load configuration snippets from the
# 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 ++ (getDepsRecursively enabledExtensions)));
extNames = map getExtName enabledExtensions;
extraInit = writeText "php.ini" ''
${lib.concatStringsSep "\n"
(lib.textClosureList extensionTexts extNames)}
${extraConfig}
'';
phpWithExtensions = symlinkJoin rec {
name = "php-with-extensions-${version}";
inherit (php) version;
nativeBuildInputs = [ makeWrapper ];
passthru = {
buildEnv = mkBuildEnv allArgs allExtensionFunctions;
withExtensions = mkWithExtensions allArgs allExtensionFunctions;
phpIni = "${phpWithExtensions}/lib/php.ini";
unwrapped = php;
tests = nixosTests.php;
inherit (php-packages) packages extensions;
};
paths = [ php ];
postBuild = ''
cp ${extraInit} $out/lib/php.ini
wrapProgram $out/bin/php --set PHP_INI_SCAN_DIR $out/lib
if test -e $out/bin/php-fpm; then
wrapProgram $out/bin/php-fpm --set PHP_INI_SCAN_DIR $out/lib
fi
'';
};
in
phpWithExtensions);
mkWithExtensions = prevArgs: prevExtensionFunctions: extensions:
mkBuildEnv prevArgs prevExtensionFunctions { inherit extensions; };
pcre' = if (lib.versionAtLeast version "7.3") then pcre2 else pcre; pcre' = if (lib.versionAtLeast version "7.3") then pcre2 else pcre;
in stdenv.mkDerivation { in
stdenv.mkDerivation {
pname = "php"; pname = "php";
inherit version; inherit version;
@ -136,6 +237,11 @@ let
outputs = [ "out" "dev" ]; outputs = [ "out" "dev" ];
passthru = {
buildEnv = mkBuildEnv {} [];
withExtensions = mkWithExtensions {} [];
};
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "An HTML-embedded scripting language"; description = "An HTML-embedded scripting language";
homepage = "https://www.php.net/"; homepage = "https://www.php.net/";
@ -146,105 +252,28 @@ let
}; };
}; };
generic' = { version, sha256, self, selfWithExtensions, ... }@args: php72base = callPackage generic (_args // {
let
php = generic (builtins.removeAttrs args [ "self" "selfWithExtensions" ]);
php-packages = (callPackage ../../../top-level/php-packages.nix {
php = self;
phpWithExtensions = selfWithExtensions;
});
buildEnv = { extensions ? (_: []), extraConfig ? "" }:
let
getExtName = ext: lib.removePrefix "php-" (builtins.parseDrvName ext.name).name;
enabledExtensions = extensions php-packages.extensions;
# Generate extension load configuration snippets from the
# 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.textClosureList extensionTexts extNames)}
${extraConfig}
'';
in
symlinkJoin {
name = "php-with-extensions-${version}";
inherit (php) version;
nativeBuildInputs = [ makeWrapper ];
passthru = {
inherit buildEnv withExtensions enabledExtensions;
inherit (php-packages) packages extensions;
};
paths = [ php ];
postBuild = ''
cp ${extraInit} $out/lib/custom-php.ini
wrapProgram $out/bin/php --set PHP_INI_SCAN_DIR $out/lib
if test -e $out/bin/php-fpm; then
wrapProgram $out/bin/php-fpm --set PHP_INI_SCAN_DIR $out/lib
fi
'';
};
withExtensions = extensions: buildEnv { inherit extensions; };
in
php.overrideAttrs (_: {
passthru = {
enabledExtensions = [];
inherit buildEnv withExtensions;
inherit (php-packages) packages extensions;
};
});
php72base = generic' {
version = "7.2.29"; version = "7.2.29";
sha256 = "08xry2fgqgg8s0ym1hh11wkbr36av3zq1bn4krbciw1b7x8gb8ga"; sha256 = "08xry2fgqgg8s0ym1hh11wkbr36av3zq1bn4krbciw1b7x8gb8ga";
self = php72base;
selfWithExtensions = php72;
# https://bugs.php.net/bug.php?id=76826 # https://bugs.php.net/bug.php?id=76826
extraPatches = lib.optional stdenv.isDarwin ./php72-darwin-isfinite.patch; extraPatches = lib.optional stdenv.isDarwin ./php72-darwin-isfinite.patch;
}; });
php73base = generic' { php73base = callPackage generic (_args // {
version = "7.3.16"; version = "7.3.16";
sha256 = "0bh499v9dfgh9k51w4rird1slb9rh9whp5h37fb84c98d992s1xq"; sha256 = "0bh499v9dfgh9k51w4rird1slb9rh9whp5h37fb84c98d992s1xq";
self = php73base;
selfWithExtensions = php73;
# https://bugs.php.net/bug.php?id=76826 # https://bugs.php.net/bug.php?id=76826
extraPatches = lib.optional stdenv.isDarwin ./php73-darwin-isfinite.patch; extraPatches = lib.optional stdenv.isDarwin ./php73-darwin-isfinite.patch;
}; });
php74base = generic' { php74base = callPackage generic (_args // {
version = "7.4.4"; version = "7.4.4";
sha256 = "17w2m4phhpj76x5fx67vgjrlkcczqvky3f5in1kjg2pch90qz3ih"; sha256 = "17w2m4phhpj76x5fx67vgjrlkcczqvky3f5in1kjg2pch90qz3ih";
self = php74base; });
selfWithExtensions = php74;
};
defaultPhpExtensions = extensions: with extensions; ([ defaultPhpExtensions = { all, ... }: with all; ([
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
@ -252,13 +281,13 @@ let
tokenizer xmlreader xmlwriter zip zlib tokenizer xmlreader xmlwriter zip zlib
] ++ lib.optionals (!stdenv.isDarwin) [ imap ]); ] ++ lib.optionals (!stdenv.isDarwin) [ imap ]);
defaultPhpExtensionsWithHash = extensions: defaultPhpExtensionsWithHash = { all, ... }:
(defaultPhpExtensions extensions) ++ [ extensions.hash ]; (defaultPhpExtensions { inherit all; }) ++ [ all.hash ];
php74 = php74base.withExtensions defaultPhpExtensions; php74 = php74base.withExtensions defaultPhpExtensions;
php73 = php73base.withExtensions defaultPhpExtensionsWithHash; php73 = php73base.withExtensions defaultPhpExtensionsWithHash;
php72 = php72base.withExtensions defaultPhpExtensionsWithHash; php72 = php72base.withExtensions defaultPhpExtensionsWithHash;
in { in {
inherit php72base php73base php74base php72 php73 php74; inherit php72 php73 php74;
} }

View file

@ -1,8 +1,8 @@
{ stdenv, fetchFromGitHub, which { stdenv, fetchFromGitHub, which
, withPython2 ? false, python2 , withPython2 ? false, python2
, withPython3 ? true, python3, ncurses , withPython3 ? true, python3, ncurses
, withPHP72 ? false, php72base , withPHP72 ? false, php72
, withPHP73 ? true, php73base , withPHP73 ? true, php73
, withPerl528 ? false, perl528 , withPerl528 ? false, perl528
, withPerl530 ? true, perl530 , withPerl530 ? true, perl530
, withPerldevel ? false, perldevel , withPerldevel ? false, perldevel
@ -18,16 +18,16 @@ with stdenv.lib;
let let
phpConfig = { phpConfig = {
config.php.embed = true; embedSupport = true;
config.php.apxs2 = false; apxs2Support = false;
config.php.systemd = false; systemdSupport = false;
config.php.phpdbg = false; phpdbgSupport = false;
config.php.cgi = false; cgiSupport = false;
config.php.fpm = false; fpmSupport = false;
}; };
php72-unit = php72base.override phpConfig; php72-unit = php72.override phpConfig;
php73-unit = php73base.override phpConfig; php73-unit = php73.override phpConfig;
in stdenv.mkDerivation rec { in stdenv.mkDerivation rec {
version = "1.16.0"; version = "1.16.0";
pname = "unit"; pname = "unit";
@ -71,8 +71,8 @@ in stdenv.mkDerivation rec {
postConfigure = '' postConfigure = ''
${optionalString withPython2 "./configure python --module=python2 --config=${python2}/bin/python2-config --lib-path=${python2}/lib"} ${optionalString withPython2 "./configure python --module=python2 --config=${python2}/bin/python2-config --lib-path=${python2}/lib"}
${optionalString withPython3 "./configure python --module=python3 --config=${python3}/bin/python3-config --lib-path=${python3}/lib"} ${optionalString withPython3 "./configure python --module=python3 --config=${python3}/bin/python3-config --lib-path=${python3}/lib"}
${optionalString withPHP72 "./configure php --module=php72 --config=${php72-unit.dev}/bin/php-config --lib-path=${php72-unit}/lib"} ${optionalString withPHP72 "./configure php --module=php72 --config=${php72-unit.unwrapped.dev}/bin/php-config --lib-path=${php72-unit}/lib"}
${optionalString withPHP73 "./configure php --module=php73 --config=${php73-unit.dev}/bin/php-config --lib-path=${php73-unit}/lib"} ${optionalString withPHP73 "./configure php --module=php73 --config=${php73-unit.unwrapped.dev}/bin/php-config --lib-path=${php73-unit}/lib"}
${optionalString withPerl528 "./configure perl --module=perl528 --perl=${perl528}/bin/perl"} ${optionalString withPerl528 "./configure perl --module=perl528 --perl=${perl528}/bin/perl"}
${optionalString withPerl530 "./configure perl --module=perl530 --perl=${perl530}/bin/perl"} ${optionalString withPerl530 "./configure perl --module=perl530 --perl=${perl530}/bin/perl"}
${optionalString withPerldevel "./configure perl --module=perldev --perl=${perldevel}/bin/perl"} ${optionalString withPerldevel "./configure perl --module=perldev --perl=${perldevel}/bin/perl"}

View file

@ -8,8 +8,8 @@
}: }:
let php-embed = php.override { let php-embed = php.override {
config.php.embed = true; embedSupport = true;
config.php.apxs2 = false; apxs2Support = false;
}; };
pythonPlugin = pkg : lib.nameValuePair "python${if pkg.isPy2 then "2" else "3"}" { pythonPlugin = pkg : lib.nameValuePair "python${if pkg.isPy2 then "2" else "3"}" {

View file

@ -339,48 +339,50 @@ mapAliases ({
pg_tmp = ephemeralpg; # added 2018-01-16 pg_tmp = ephemeralpg; # added 2018-01-16
php-embed = throw '' php-embed = throw ''
php*-embed has been dropped, you can build the same package by using php*-embed has been dropped, you can build something similar
something similar with this following snippet: with the following snippet:
(php74.override { config.php.embed = true; config.php.apxs2 = false; }) php74.override { embedSupport = true; apxs2Support = false; }
''; # added 2020-04-01 ''; # added 2020-04-01
php72-embed = php-embed; # added 2020-04-01 php72-embed = php-embed; # added 2020-04-01
php73-embed = php-embed; # added 2020-04-01 php73-embed = php-embed; # added 2020-04-01
php74-embed = php-embed; # added 2020-04-01 php74-embed = php-embed; # added 2020-04-01
phpPackages-embed = throw '' phpPackages-embed = throw ''
php*Packages-embed has been dropped, you can build the same package by using php*Packages-embed has been dropped, you can build something
something similar with this following snippet: similar with the following snippet:
(php74.override { config.php.embed = true; config.php.apxs2 = false; }).packages (php74.override { embedSupport = true; apxs2Support = false; }).packages
''; # added 2020-04-01 ''; # added 2020-04-01
php74Packages-embed = phpPackages-embed; php74Packages-embed = phpPackages-embed;
php73Packages-embed = phpPackages-embed; php73Packages-embed = phpPackages-embed;
php72Packages-embed = phpPackages-embed; php72Packages-embed = phpPackages-embed;
php-unit = throw '' php-unit = throw ''
php*-unit has been dropped, you can build the same package by using php*-unit has been dropped, you can build something similar with
something similar with this following snippet: the following snippet:
(php74.override { php74.override {
config.php.embed = true; embedSupport = true;
config.php.apxs2 = false; apxs2Support = false;
config.php.systemd = false; systemdSupport = false;
config.php.phpdbg = false; phpdbgSupport = false;
config.php.cgi = false; cgiSupport = false;
config.php.fpm = false; }) fpmSupport = false;
}
''; # added 2020-04-01 ''; # added 2020-04-01
php72-unit = php-unit; # added 2020-04-01 php72-unit = php-unit; # added 2020-04-01
php73-unit = php-unit; # added 2020-04-01 php73-unit = php-unit; # added 2020-04-01
php74-unit = php-unit; # added 2020-04-01 php74-unit = php-unit; # added 2020-04-01
phpPackages-unit = throw '' phpPackages-unit = throw ''
php*Packages-unit has been dropped, you can build the same package by using php*Packages-unit has been dropped, you can build something
something similar with this following snippet: similar with this following snippet:
(php74.override { (php74.override {
config.php.embed = true; embedSupport = true;
config.php.apxs2 = false; apxs2Support = false;
config.php.systemd = false; systemdSupport = false;
config.php.phpdbg = false; phpdbgSupport = false;
config.php.cgi = false; cgiSupport = false;
config.php.fpm = false; }).packages fpmSupport = false;
}).packages
''; # added 2020-04-01 ''; # added 2020-04-01
php74Packages-unit = phpPackages-unit; php74Packages-unit = phpPackages-unit;
php73Packages-unit = phpPackages-unit; php73Packages-unit = phpPackages-unit;

View file

@ -9457,9 +9457,9 @@ 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;
picoc = callPackage ../development/interpreters/picoc {}; picoc = callPackage ../development/interpreters/picoc {};

View file

@ -1,4 +1,4 @@
{ stdenv, lib, pkgs, fetchgit, php, phpWithExtensions, autoconf, pkgconfig, re2c { stdenv, lib, pkgs, fetchgit, php, autoconf, pkgconfig, re2c
, gettext, bzip2, curl, libxml2, openssl, gmp, icu, oniguruma, libsodium , gettext, bzip2, curl, libxml2, openssl, gmp, icu, 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
@ -8,7 +8,8 @@
let let
buildPecl = import ../build-support/build-pecl.nix { buildPecl = import ../build-support/build-pecl.nix {
inherit php lib; php = php.unwrapped;
inherit lib;
inherit (pkgs) stdenv autoreconfHook fetchurl re2c; inherit (pkgs) stdenv autoreconfHook fetchurl re2c;
}; };
@ -43,7 +44,7 @@ in
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
install -D $src $out/libexec/box/box.phar install -D $src $out/libexec/box/box.phar
makeWrapper ${phpWithExtensions}/bin/php $out/bin/box \ makeWrapper ${php}/bin/php $out/bin/box \
--add-flags "-d phar.readonly=0 $out/libexec/box/box.phar" --add-flags "-d phar.readonly=0 $out/libexec/box/box.phar"
''; '';
@ -71,7 +72,7 @@ in
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
install -D $src $out/libexec/composer/composer.phar install -D $src $out/libexec/composer/composer.phar
makeWrapper ${phpWithExtensions}/bin/php $out/bin/composer \ makeWrapper ${php}/bin/php $out/bin/composer \
--add-flags "$out/libexec/composer/composer.phar" \ --add-flags "$out/libexec/composer/composer.phar" \
--prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.unzip ]} --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.unzip ]}
''; '';
@ -163,7 +164,7 @@ in
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
install -D $src $out/libexec/phpcbf/phpcbf.phar install -D $src $out/libexec/phpcbf/phpcbf.phar
makeWrapper ${phpWithExtensions}/bin/php $out/bin/phpcbf \ makeWrapper ${php}/bin/php $out/bin/phpcbf \
--add-flags "$out/libexec/phpcbf/phpcbf.phar" --add-flags "$out/libexec/phpcbf/phpcbf.phar"
''; '';
@ -190,7 +191,7 @@ in
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
install -D $src $out/libexec/phpcs/phpcs.phar install -D $src $out/libexec/phpcs/phpcs.phar
makeWrapper ${phpWithExtensions}/bin/php $out/bin/phpcs \ makeWrapper ${php}/bin/php $out/bin/phpcs \
--add-flags "$out/libexec/phpcs/phpcs.phar" --add-flags "$out/libexec/phpcs/phpcs.phar"
''; '';
@ -217,7 +218,7 @@ in
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
install -D $src $out/libexec/phpstan/phpstan.phar install -D $src $out/libexec/phpstan/phpstan.phar
makeWrapper ${phpWithExtensions}/bin/php $out/bin/phpstan \ makeWrapper ${php}/bin/php $out/bin/phpstan \
--add-flags "$out/libexec/phpstan/phpstan.phar" --add-flags "$out/libexec/phpstan/phpstan.phar"
''; '';
@ -537,7 +538,7 @@ in
}; };
pdo_oci = buildPecl rec { pdo_oci = buildPecl rec {
inherit (php) src version; inherit (php.unwrapped) src version;
pname = "pdo_oci"; pname = "pdo_oci";
sourceRoot = "php-${version}/ext/pdo_oci"; sourceRoot = "php-${version}/ext/pdo_oci";
@ -746,11 +747,11 @@ in
pname = "php-${name}"; pname = "php-${name}";
extensionName = name; extensionName = name;
inherit (php) version src; inherit (php.unwrapped) version src;
sourceRoot = "php-${php.version}/ext/${name}"; sourceRoot = "php-${php.version}/ext/${name}";
enableParallelBuilding = true; enableParallelBuilding = true;
nativeBuildInputs = [ php autoconf pkgconfig re2c ]; nativeBuildInputs = [ php.unwrapped autoconf pkgconfig re2c ];
inherit configureFlags internalDeps buildInputs inherit configureFlags internalDeps buildInputs
zendExtension doCheck; zendExtension doCheck;