2020-03-31 17:06:04 +00:00
|
|
|
# We have tests for PCRE and PHP-FPM in nixos/tests/php/ or
|
|
|
|
# both in the same attribute named nixosTests.php
|
|
|
|
|
2020-03-24 18:30:18 +00:00
|
|
|
{ callPackage, config, fetchurl, lib, makeWrapper, stdenv, symlinkJoin
|
|
|
|
, writeText , autoconf, automake, bison, flex, libtool, pkgconfig, re2c
|
|
|
|
, apacheHttpd, libargon2, libxml2, pcre, pcre2 , systemd, valgrind
|
|
|
|
}:
|
2015-08-11 11:13:28 +00:00
|
|
|
|
2018-07-21 15:41:48 +00:00
|
|
|
let
|
2015-08-11 11:13:28 +00:00
|
|
|
generic =
|
2018-07-21 15:41:48 +00:00
|
|
|
{ version
|
|
|
|
, sha256
|
2018-11-27 00:39:20 +00:00
|
|
|
, extraPatches ? []
|
2020-03-15 16:57:34 +00:00
|
|
|
|
|
|
|
# Sapi flags
|
2018-12-10 07:25:31 +00:00
|
|
|
, cgiSupport ? config.php.cgi or true
|
|
|
|
, cliSupport ? config.php.cli or true
|
2020-03-15 16:57:34 +00:00
|
|
|
, fpmSupport ? config.php.fpm or true
|
|
|
|
, pearSupport ? config.php.pear or true
|
2018-12-10 07:25:31 +00:00
|
|
|
, pharSupport ? config.php.phar or true
|
2020-03-15 16:57:34 +00:00
|
|
|
, phpdbgSupport ? config.php.phpdbg or true
|
|
|
|
|
|
|
|
|
|
|
|
# Misc flags
|
|
|
|
, apxs2Support ? config.php.apxs2 or (!stdenv.isDarwin)
|
|
|
|
, argon2Support ? config.php.argon2 or true
|
2019-06-06 19:16:58 +00:00
|
|
|
, cgotoSupport ? config.php.cgoto or false
|
2020-03-15 16:57:34 +00:00
|
|
|
, embedSupport ? config.php.embed or false
|
2019-12-10 17:26:58 +00:00
|
|
|
, ipv6Support ? config.php.ipv6 or true
|
2020-03-15 16:57:34 +00:00
|
|
|
, systemdSupport ? config.php.systemd or stdenv.isLinux
|
|
|
|
, valgrindSupport ? config.php.valgrind or true
|
|
|
|
, ztsSupport ? (config.php.zts or false) || (apxs2Support)
|
|
|
|
}: let
|
|
|
|
pcre' = if (lib.versionAtLeast version "7.3") then pcre2 else pcre;
|
|
|
|
in stdenv.mkDerivation {
|
2020-03-15 09:27:37 +00:00
|
|
|
pname = "php";
|
2018-07-21 15:41:48 +00:00
|
|
|
|
2020-03-15 09:27:37 +00:00
|
|
|
inherit version;
|
2015-08-11 11:13:28 +00:00
|
|
|
|
2020-03-15 09:27:37 +00:00
|
|
|
enableParallelBuilding = true;
|
2015-08-11 11:13:28 +00:00
|
|
|
|
2020-03-15 16:57:34 +00:00
|
|
|
nativeBuildInputs = [ autoconf automake bison flex libtool pkgconfig re2c ];
|
2015-08-11 11:13:28 +00:00
|
|
|
|
2020-03-24 18:30:18 +00:00
|
|
|
buildInputs =
|
|
|
|
# PCRE extension
|
|
|
|
[ pcre' ]
|
2020-03-15 16:57:34 +00:00
|
|
|
|
|
|
|
# Enable sapis
|
|
|
|
++ lib.optional pearSupport [ libxml2.dev ]
|
|
|
|
|
|
|
|
# Misc deps
|
2020-03-15 16:51:28 +00:00
|
|
|
++ lib.optional apxs2Support apacheHttpd
|
|
|
|
++ lib.optional argon2Support libargon2
|
2020-03-15 16:57:34 +00:00
|
|
|
++ lib.optional systemdSupport systemd
|
|
|
|
++ lib.optional valgrindSupport valgrind
|
|
|
|
;
|
2015-08-11 11:13:28 +00:00
|
|
|
|
2020-03-15 16:51:28 +00:00
|
|
|
CXXFLAGS = lib.optionalString stdenv.cc.isClang "-std=c++11";
|
2019-12-10 17:40:33 +00:00
|
|
|
|
2020-03-24 18:30:18 +00:00
|
|
|
configureFlags =
|
2020-03-15 16:57:34 +00:00
|
|
|
# Disable all extensions
|
2020-03-24 18:30:18 +00:00
|
|
|
[ "--disable-all" ]
|
2020-03-15 16:57:34 +00:00
|
|
|
|
|
|
|
# PCRE
|
|
|
|
++ lib.optionals (lib.versionAtLeast version "7.4") [ "--with-external-pcre=${pcre'.dev}" ]
|
|
|
|
++ lib.optionals (lib.versions.majorMinor version == "7.3") [ "--with-pcre-regex=${pcre'.dev}" ]
|
|
|
|
++ lib.optionals (lib.versionOlder version "7.3") [ "--with-pcre-regex=${pcre'.dev}" ]
|
|
|
|
++ [ "PCRE_LIBDIR=${pcre'}" ]
|
|
|
|
|
|
|
|
|
|
|
|
# Enable sapis
|
2020-03-15 16:51:28 +00:00
|
|
|
++ lib.optional (!cgiSupport) "--disable-cgi"
|
|
|
|
++ lib.optional (!cliSupport) "--disable-cli"
|
2020-03-15 16:57:34 +00:00
|
|
|
++ lib.optional fpmSupport "--enable-fpm"
|
|
|
|
++ lib.optional pearSupport [ "--with-pear=$(out)/lib/php/pear" "--enable-xml" "--with-libxml" ]
|
|
|
|
++ lib.optional (pearSupport && (lib.versionOlder version "7.4")) "--enable-libxml"
|
|
|
|
++ lib.optional pharSupport "--enable-phar"
|
|
|
|
++ lib.optional phpdbgSupport "--enable-phpdbg"
|
|
|
|
|
|
|
|
|
|
|
|
# Misc flags
|
|
|
|
++ lib.optional apxs2Support "--with-apxs2=${apacheHttpd.dev}/bin/apxs"
|
|
|
|
++ lib.optional argon2Support "--with-password-argon2=${libargon2}"
|
2020-03-15 16:51:28 +00:00
|
|
|
++ lib.optional cgotoSupport "--enable-re2c-cgoto"
|
2020-03-15 16:57:34 +00:00
|
|
|
++ lib.optional embedSupport "--enable-embed"
|
2020-03-15 16:51:28 +00:00
|
|
|
++ lib.optional (!ipv6Support) "--disable-ipv6"
|
2020-03-15 16:57:34 +00:00
|
|
|
++ lib.optional systemdSupport "--with-fpm-systemd"
|
|
|
|
++ lib.optional valgrindSupport "--with-valgrind=${valgrind.dev}"
|
|
|
|
++ lib.optional ztsSupport "--enable-maintainer-zts"
|
|
|
|
;
|
2015-08-11 11:13:28 +00:00
|
|
|
|
2020-03-15 09:27:37 +00:00
|
|
|
hardeningDisable = [ "bindnow" ];
|
2016-03-05 23:15:18 +00:00
|
|
|
|
2020-03-15 09:27:37 +00:00
|
|
|
preConfigure = ''
|
|
|
|
# Don't record the configure flags since this causes unnecessary
|
|
|
|
# runtime dependencies
|
|
|
|
for i in main/build-defs.h.in scripts/php-config.in; do
|
|
|
|
substituteInPlace $i \
|
|
|
|
--replace '@CONFIGURE_COMMAND@' '(omitted)' \
|
|
|
|
--replace '@CONFIGURE_OPTIONS@' "" \
|
|
|
|
--replace '@PHP_LDFLAGS@' ""
|
|
|
|
done
|
2015-08-11 11:13:28 +00:00
|
|
|
|
2020-03-15 09:27:37 +00:00
|
|
|
export EXTENSION_DIR=$out/lib/php/extensions
|
2017-06-01 21:16:19 +00:00
|
|
|
|
2020-03-15 09:27:37 +00:00
|
|
|
./buildconf --copy --force
|
2019-12-10 17:40:33 +00:00
|
|
|
|
2020-03-15 09:27:37 +00:00
|
|
|
if test -f $src/genfiles; then
|
|
|
|
./genfiles
|
|
|
|
fi
|
2020-03-15 16:51:28 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
2020-03-15 09:27:37 +00:00
|
|
|
substituteInPlace configure --replace "-lstdc++" "-lc++"
|
|
|
|
'';
|
2015-08-11 11:13:28 +00:00
|
|
|
|
2020-03-15 09:27:37 +00:00
|
|
|
postInstall = ''
|
|
|
|
test -d $out/etc || mkdir $out/etc
|
|
|
|
cp php.ini-production $out/etc/php.ini
|
|
|
|
'';
|
2015-08-11 11:13:28 +00:00
|
|
|
|
2020-03-15 09:27:37 +00:00
|
|
|
postFixup = ''
|
|
|
|
mkdir -p $dev/bin $dev/share/man/man1
|
|
|
|
mv $out/bin/phpize $out/bin/php-config $dev/bin/
|
|
|
|
mv $out/share/man/man1/phpize.1.gz \
|
|
|
|
$out/share/man/man1/php-config.1.gz \
|
|
|
|
$dev/share/man/man1/
|
|
|
|
'';
|
2017-04-02 15:35:21 +00:00
|
|
|
|
2020-03-15 09:27:37 +00:00
|
|
|
src = fetchurl {
|
|
|
|
url = "https://www.php.net/distributions/php-${version}.tar.bz2";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
2015-08-11 11:13:28 +00:00
|
|
|
|
2020-03-15 16:57:34 +00:00
|
|
|
patches = [ ./fix-paths-php7.patch ] ++ extraPatches;
|
|
|
|
|
|
|
|
separateDebugInfo = true;
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2020-03-15 09:27:37 +00:00
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "An HTML-embedded scripting language";
|
2020-03-15 16:51:28 +00:00
|
|
|
homepage = "https://www.php.net/";
|
2020-03-15 09:27:37 +00:00
|
|
|
license = licenses.php301;
|
|
|
|
maintainers = with maintainers; [ globin etu ma27 ];
|
|
|
|
platforms = platforms.all;
|
|
|
|
outputsToInstall = [ "out" "dev" ];
|
|
|
|
};
|
|
|
|
};
|
2017-03-20 15:56:12 +00:00
|
|
|
|
2020-03-28 21:37:22 +00:00
|
|
|
generic' = { version, sha256, self, selfWithExtensions, ... }@args:
|
2020-03-24 18:57:49 +00:00
|
|
|
let
|
2020-03-28 21:37:22 +00:00
|
|
|
php = generic (builtins.removeAttrs args [ "self" "selfWithExtensions" ]);
|
2020-04-02 20:13:04 +00:00
|
|
|
|
2020-04-03 16:14:26 +00:00
|
|
|
php-packages = (callPackage ../../../top-level/php-packages.nix {
|
2020-03-28 21:37:22 +00:00
|
|
|
php = self;
|
|
|
|
phpWithExtensions = selfWithExtensions;
|
2020-04-03 16:14:26 +00:00
|
|
|
});
|
2020-04-02 20:13:04 +00:00
|
|
|
|
2020-04-03 16:14:26 +00:00
|
|
|
buildEnv = { extensions ? (_: []), extraConfig ? "" }:
|
2020-03-24 18:57:49 +00:00
|
|
|
let
|
|
|
|
getExtName = ext: lib.removePrefix "php-" (builtins.parseDrvName ext.name).name;
|
2020-04-05 13:56:28 +00:00
|
|
|
enabledExtensions = extensions php-packages.extensions;
|
2020-04-03 16:14:26 +00:00
|
|
|
|
|
|
|
# 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.
|
2020-03-24 18:57:49 +00:00
|
|
|
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";
|
2020-03-28 22:03:35 +00:00
|
|
|
deps = lib.optionals (ext ? internalDeps)
|
|
|
|
(map getExtName ext.internalDeps);
|
2020-03-24 18:57:49 +00:00
|
|
|
})
|
2020-04-05 13:56:28 +00:00
|
|
|
enabledExtensions);
|
2020-03-24 18:57:49 +00:00
|
|
|
|
2020-04-05 13:56:28 +00:00
|
|
|
extNames = map getExtName enabledExtensions;
|
2020-03-24 18:57:49 +00:00
|
|
|
extraInit = writeText "custom-php.ini" ''
|
|
|
|
${lib.concatStringsSep "\n"
|
|
|
|
(lib.textClosureList extensionTexts extNames)}
|
2020-03-29 10:01:38 +00:00
|
|
|
${extraConfig}
|
2020-03-24 18:57:49 +00:00
|
|
|
'';
|
|
|
|
in
|
|
|
|
symlinkJoin {
|
|
|
|
name = "php-with-extensions-${version}";
|
2020-04-08 13:13:07 +00:00
|
|
|
inherit (php) version;
|
2020-03-24 18:57:49 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2020-03-28 21:37:22 +00:00
|
|
|
passthru = {
|
2020-04-05 13:56:28 +00:00
|
|
|
inherit buildEnv withExtensions enabledExtensions;
|
2020-04-03 16:14:26 +00:00
|
|
|
inherit (php-packages) packages extensions;
|
2020-03-28 21:37:22 +00:00
|
|
|
};
|
2020-03-24 18:57:49 +00:00
|
|
|
paths = [ php ];
|
|
|
|
postBuild = ''
|
2020-03-28 08:57:04 +00:00
|
|
|
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
|
2020-03-24 18:57:49 +00:00
|
|
|
'';
|
|
|
|
};
|
2020-04-03 16:18:36 +00:00
|
|
|
|
|
|
|
withExtensions = extensions: buildEnv { inherit extensions; };
|
2020-03-24 18:57:49 +00:00
|
|
|
in
|
|
|
|
php.overrideAttrs (_: {
|
2020-03-28 21:37:22 +00:00
|
|
|
passthru = {
|
2020-04-05 13:56:28 +00:00
|
|
|
enabledExtensions = [];
|
2020-04-03 16:18:36 +00:00
|
|
|
inherit buildEnv withExtensions;
|
2020-04-03 16:14:26 +00:00
|
|
|
inherit (php-packages) packages extensions;
|
2020-03-28 21:37:22 +00:00
|
|
|
};
|
2020-03-24 18:57:49 +00:00
|
|
|
});
|
2020-02-06 19:05:34 +00:00
|
|
|
|
2020-03-22 17:58:23 +00:00
|
|
|
php72base = generic' {
|
2020-04-05 20:06:30 +00:00
|
|
|
version = "7.2.29";
|
|
|
|
sha256 = "08xry2fgqgg8s0ym1hh11wkbr36av3zq1bn4krbciw1b7x8gb8ga";
|
2020-03-28 21:37:22 +00:00
|
|
|
self = php72base;
|
|
|
|
selfWithExtensions = php72;
|
2018-09-22 18:22:57 +00:00
|
|
|
|
2018-11-27 00:39:20 +00:00
|
|
|
# https://bugs.php.net/bug.php?id=76826
|
2020-03-15 16:51:28 +00:00
|
|
|
extraPatches = lib.optional stdenv.isDarwin ./php72-darwin-isfinite.patch;
|
2018-11-27 00:39:20 +00:00
|
|
|
};
|
2018-12-08 17:10:11 +00:00
|
|
|
|
2020-03-22 17:58:23 +00:00
|
|
|
php73base = generic' {
|
2020-04-05 20:05:57 +00:00
|
|
|
version = "7.3.16";
|
|
|
|
sha256 = "0bh499v9dfgh9k51w4rird1slb9rh9whp5h37fb84c98d992s1xq";
|
2020-03-28 21:37:22 +00:00
|
|
|
self = php73base;
|
|
|
|
selfWithExtensions = php73;
|
2018-12-10 09:23:56 +00:00
|
|
|
|
2018-12-10 09:34:35 +00:00
|
|
|
# https://bugs.php.net/bug.php?id=76826
|
2020-03-15 16:51:28 +00:00
|
|
|
extraPatches = lib.optional stdenv.isDarwin ./php73-darwin-isfinite.patch;
|
2018-12-08 17:10:11 +00:00
|
|
|
};
|
2019-11-21 21:19:01 +00:00
|
|
|
|
2020-03-22 17:58:23 +00:00
|
|
|
php74base = generic' {
|
2020-04-05 20:05:16 +00:00
|
|
|
version = "7.4.4";
|
|
|
|
sha256 = "17w2m4phhpj76x5fx67vgjrlkcczqvky3f5in1kjg2pch90qz3ih";
|
2020-03-28 21:37:22 +00:00
|
|
|
self = php74base;
|
|
|
|
selfWithExtensions = php74;
|
2019-11-27 10:12:08 +00:00
|
|
|
};
|
2020-03-22 17:58:23 +00:00
|
|
|
|
2020-04-03 16:18:36 +00:00
|
|
|
defaultPhpExtensions = extensions: with extensions; ([
|
|
|
|
bcmath calendar curl ctype dom exif fileinfo filter ftp gd
|
|
|
|
gettext gmp iconv intl json ldap mbstring mysqli mysqlnd opcache
|
|
|
|
openssl pcntl pdo pdo_mysql pdo_odbc pdo_pgsql pdo_sqlite pgsql
|
|
|
|
posix readline session simplexml sockets soap sodium sqlite3
|
|
|
|
tokenizer xmlreader xmlwriter zip zlib
|
|
|
|
] ++ lib.optionals (!stdenv.isDarwin) [ imap ]);
|
|
|
|
|
2020-04-03 16:55:03 +00:00
|
|
|
defaultPhpExtensionsWithHash = extensions:
|
|
|
|
(defaultPhpExtensions extensions) ++ [ extensions.hash ];
|
|
|
|
|
2020-04-03 16:18:36 +00:00
|
|
|
php74 = php74base.withExtensions defaultPhpExtensions;
|
2020-04-03 16:55:03 +00:00
|
|
|
php73 = php73base.withExtensions defaultPhpExtensionsWithHash;
|
|
|
|
php72 = php72base.withExtensions defaultPhpExtensionsWithHash;
|
2020-03-28 21:37:22 +00:00
|
|
|
|
|
|
|
in {
|
|
|
|
inherit php72base php73base php74base php72 php73 php74;
|
2015-08-11 11:13:28 +00:00
|
|
|
}
|