php: Make all arguments to a PHP build overridable
Make all arguments to a PHP build overridable; i.e, both configuration flags, such as valgrindSupport, and packages, such as valgrind: php.override { valgrindSupport = false; valgrind = valgrind-light; } This applies to packages built by generic and buildEnv/withExtensions; i.e, it works with both phpXX and phpXXBase packages. The following changes were also made to facilitate this: - generic and generic' are merged into one function - generic now takes all required arguments for a complete build and is meant to be called by callPackage - The main function called from all-packages.nix no longer takes all required arguments for a complete build - all arguments passed to it are however forwarded to the individual builds, thus default arguments can still be overridden from all-packages.nix
This commit is contained in:
parent
a463261415
commit
dde5f5f899
1 changed files with 217 additions and 213 deletions
|
@ -1,17 +1,21 @@
|
||||||
# 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 }@_args:
|
||||||
, writeText , autoconf, automake, bison, flex, libtool, pkgconfig, re2c
|
|
||||||
, apacheHttpd, libargon2, libxml2, pcre, pcre2 , systemd, valgrind
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
let
|
||||||
generic =
|
generic =
|
||||||
{ version
|
{ callPackage, lib, stdenv, config, fetchurl, makeWrapper
|
||||||
|
, symlinkJoin, writeText, autoconf, automake, bison, flex, libtool
|
||||||
|
, pkgconfig, re2c, apacheHttpd, libargon2, libxml2, pcre, pcre2
|
||||||
|
, systemd, valgrind
|
||||||
|
|
||||||
|
, version
|
||||||
, sha256
|
, sha256
|
||||||
, extraPatches ? []
|
, extraPatches ? []
|
||||||
|
|
||||||
|
, defaultPhpExtensions
|
||||||
|
|
||||||
# Sapi flags
|
# Sapi flags
|
||||||
, cgiSupport ? config.php.cgi or true
|
, cgiSupport ? config.php.cgi or true
|
||||||
, cliSupport ? config.php.cli or true
|
, cliSupport ? config.php.cli or true
|
||||||
|
@ -30,9 +34,83 @@ let
|
||||||
, systemdSupport ? config.php.systemd or stdenv.isLinux
|
, systemdSupport ? config.php.systemd or stdenv.isLinux
|
||||||
, valgrindSupport ? config.php.valgrind or true
|
, valgrindSupport ? config.php.valgrind or true
|
||||||
, ztsSupport ? (config.php.zts or false) || (apxs2Support)
|
, ztsSupport ? (config.php.zts or false) || (apxs2Support)
|
||||||
}: let
|
}@args:
|
||||||
|
let
|
||||||
|
self = generic args;
|
||||||
|
|
||||||
|
php-packages = (callPackage ../../../top-level/php-packages.nix {
|
||||||
|
php = self;
|
||||||
|
phpWithExtensions = self.withExtensions defaultPhpExtensions;
|
||||||
|
});
|
||||||
|
|
||||||
|
buildEnv = lib.makeOverridable (
|
||||||
|
{ extensions ? (_: []), extraConfig ? "", ... }@innerArgs:
|
||||||
|
let
|
||||||
|
filteredInnerArgs = builtins.removeAttrs innerArgs [ "extensions" "extraConfig" ];
|
||||||
|
allArgs = args // filteredInnerArgs;
|
||||||
|
php = generic allArgs;
|
||||||
|
|
||||||
|
php-packages = (callPackage ../../../top-level/php-packages.nix {
|
||||||
|
inherit php phpWithExtensions;
|
||||||
|
});
|
||||||
|
|
||||||
|
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}
|
||||||
|
'';
|
||||||
|
|
||||||
|
phpWithExtensions = symlinkJoin rec {
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
|
phpWithExtensions);
|
||||||
|
|
||||||
|
withExtensions = extensions: buildEnv { 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 +214,12 @@ let
|
||||||
|
|
||||||
outputs = [ "out" "dev" ];
|
outputs = [ "out" "dev" ];
|
||||||
|
|
||||||
|
passthru = {
|
||||||
|
enabledExtensions = [];
|
||||||
|
inherit buildEnv withExtensions;
|
||||||
|
inherit (php-packages) packages extensions;
|
||||||
|
};
|
||||||
|
|
||||||
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,109 +230,29 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
generic' = { version, sha256, self, selfWithExtensions, ... }@args:
|
php72base = callPackage generic (_args // {
|
||||||
let
|
|
||||||
filteredArgs = builtins.removeAttrs args [ "self" "selfWithExtensions" ];
|
|
||||||
php = generic filteredArgs;
|
|
||||||
|
|
||||||
php-packages = (callPackage ../../../top-level/php-packages.nix {
|
|
||||||
php = self;
|
|
||||||
phpWithExtensions = selfWithExtensions;
|
|
||||||
});
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
# 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;
|
defaultPhpExtensions = defaultPhpExtensionsWithHash;
|
||||||
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;
|
defaultPhpExtensions = defaultPhpExtensionsWithHash;
|
||||||
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;
|
inherit defaultPhpExtensions;
|
||||||
selfWithExtensions = php74;
|
});
|
||||||
};
|
|
||||||
|
|
||||||
defaultPhpExtensions = extensions: with extensions; ([
|
defaultPhpExtensions = extensions: with extensions; ([
|
||||||
bcmath calendar curl ctype dom exif fileinfo filter ftp gd
|
bcmath calendar curl ctype dom exif fileinfo filter ftp gd
|
||||||
|
|
Loading…
Reference in a new issue