php: Build an even slimmer base
This moves yet more extensions from the base build to phpPackages.ext. Some of the extensions are a bit quirky and need patching for this to work, most notably mysqlnd and opcache. Two new parameters are introduced for mkExtension - internalDeps and postPhpize. internalDeps is used to specify which other internal extensions the current extension depends on, in order to provide them at build time. postPhpize is for when patches and quirks need to be applied after running phpize. Patch notes: - For opcache, older versions of PHP have a bug where header files are included in the wrong order. - For mysqlnd, the config.h is never included, so we include it in the main header file, mysqlnd.h. Also, the configure script doesn't add the necessary library link flags, so we add them to the variable configure should have added them to.
This commit is contained in:
parent
da8ca2be2f
commit
282337799b
|
@ -1,8 +1,8 @@
|
|||
# pcre functionality is tested in nixos/tests/php-pcre.nix
|
||||
{ callPackage, config, fetchurl, lib, makeWrapper, stdenv, symlinkJoin, writeText
|
||||
, autoconf, automake, bison, flex, libtool, pkgconfig, re2c
|
||||
, apacheHttpd, gettext, libargon2, libxml2, openssl, pcre, pcre2, readline
|
||||
, sqlite, systemd, valgrind, zlib, oniguruma }:
|
||||
{ callPackage, config, fetchurl, lib, makeWrapper, stdenv, symlinkJoin
|
||||
, writeText , autoconf, automake, bison, flex, libtool, pkgconfig, re2c
|
||||
, apacheHttpd, libargon2, libxml2, pcre, pcre2 , systemd, valgrind
|
||||
}:
|
||||
|
||||
let
|
||||
generic =
|
||||
|
@ -10,9 +10,6 @@ let
|
|||
, sha256
|
||||
, extraPatches ? []
|
||||
|
||||
# Build a minimal php
|
||||
, minimalBuild ? config.php.minimal or false
|
||||
|
||||
# Sapi flags
|
||||
, cgiSupport ? config.php.cgi or true
|
||||
, cliSupport ? config.php.cli or true
|
||||
|
@ -42,17 +39,9 @@ let
|
|||
|
||||
nativeBuildInputs = [ autoconf automake bison flex libtool pkgconfig re2c ];
|
||||
|
||||
buildInputs = [ ]
|
||||
# Deps for some base extensions
|
||||
++ [ gettext ] # Gettext extension
|
||||
++ [ openssl openssl.dev ] # Openssl extension
|
||||
++ [ pcre' ] # PCRE extension
|
||||
++ [ readline ] # Readline extension
|
||||
++ [ zlib ] # Zlib extension
|
||||
++ [ oniguruma ] # mbstring extension
|
||||
|
||||
# Deps needed when building all default extensions
|
||||
++ lib.optionals (!minimalBuild) [ sqlite ]
|
||||
buildInputs =
|
||||
# PCRE extension
|
||||
[ pcre' ]
|
||||
|
||||
# Enable sapis
|
||||
++ lib.optional pearSupport [ libxml2.dev ]
|
||||
|
@ -66,18 +55,9 @@ let
|
|||
|
||||
CXXFLAGS = lib.optionalString stdenv.cc.isClang "-std=c++11";
|
||||
|
||||
configureFlags = []
|
||||
configureFlags =
|
||||
# Disable all extensions
|
||||
++ lib.optional minimalBuild [ "--disable-all" ]
|
||||
|
||||
# A bunch of base extensions
|
||||
++ [ "--with-gettext=${gettext}" ]
|
||||
++ [ "--with-openssl" ]
|
||||
++ [ "--with-readline=${readline.dev}" ]
|
||||
++ [ "--with-zlib=${zlib.dev}" ]
|
||||
++ [ "--enable-mysqlnd" ] # Required to be able to build mysqli and pdo_mysql
|
||||
++ [ "--enable-sockets" ]
|
||||
++ [ "--enable-mbstring" ]
|
||||
[ "--disable-all" ]
|
||||
|
||||
# PCRE
|
||||
++ lib.optionals (lib.versionAtLeast version "7.4") [ "--with-external-pcre=${pcre'.dev}" ]
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{ stdenv, lib, pkgs, fetchgit, php, autoconf, pkgconfig, re2c
|
||||
{ stdenv, lib, pkgs, fetchgit, php, autoconf, pkgconfig, re2c, gettext
|
||||
, bzip2, curl, libxml2, openssl, gmp, icu, oniguruma, libsodium, html-tidy
|
||||
, libzip, zlib, pcre, pcre2, libxslt, aspell, openldap, cyrus_sasl, uwimap
|
||||
, pam, libiconv, enchant1, libXpm, gd, libwebp, libjpeg, libpng, freetype
|
||||
, libffi, freetds, postgresql, sqlite, recode, net-snmp, unixODBC }:
|
||||
, libffi, freetds, postgresql, sqlite, net-snmp, unixODBC, libedit, readline
|
||||
}:
|
||||
|
||||
let
|
||||
self = with self; {
|
||||
|
@ -709,6 +710,8 @@ let
|
|||
mkExtension = {
|
||||
name
|
||||
, configureFlags ? [ "--enable-${name}" ]
|
||||
, internalDeps ? []
|
||||
, postPhpize ? ""
|
||||
, buildInputs ? []
|
||||
, zendExtension ? false
|
||||
, ...
|
||||
|
@ -720,10 +723,24 @@ let
|
|||
|
||||
enableParallelBuilding = true;
|
||||
nativeBuildInputs = [ php autoconf pkgconfig re2c ];
|
||||
inherit configureFlags buildInputs zendExtension;
|
||||
inherit configureFlags internalDeps buildInputs zendExtension;
|
||||
|
||||
preConfigure = "phpize";
|
||||
preConfigure = ''
|
||||
nullglobRestore=$(shopt -p nullglob)
|
||||
shopt -u nullglob # To make ?-globbing work
|
||||
|
||||
# Some extensions have a config0.m4 or config9.m4
|
||||
if [ -f config?.m4 ]; then
|
||||
mv config?.m4 config.m4
|
||||
fi
|
||||
|
||||
$nullglobRestore
|
||||
phpize
|
||||
${postPhpize}
|
||||
${lib.concatMapStringsSep "\n"
|
||||
(dep: "mkdir -p ext; ln -s ../../${dep} ext/")
|
||||
internalDeps}
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/lib/php/extensions
|
||||
cp modules/${name}.so $out/lib/php/extensions/ext-${name}.so
|
||||
|
@ -779,6 +796,10 @@ let
|
|||
"--enable-gd-jis-conv"
|
||||
];
|
||||
enable = lib.versionOlder php.version "7.4"; }
|
||||
{ name = "gettext";
|
||||
buildInputs = [ gettext ];
|
||||
postPhpize = ''substituteInPlace configure --replace 'as_fn_error $? "Cannot locate header file libintl.h" "$LINENO" 5' ':' '';
|
||||
configureFlags = "--with-gettext=${gettext}"; }
|
||||
{ name = "gmp";
|
||||
buildInputs = [ gmp ];
|
||||
configureFlags = [ "--with-gmp=${gmp.dev}" ]; }
|
||||
|
@ -804,29 +825,96 @@ let
|
|||
"LDAP_LIBDIR=${openldap.out}/lib"
|
||||
] ++ lib.optional stdenv.isLinux "--with-ldap-sasl=${cyrus_sasl.dev}"; }
|
||||
{ name = "mbstring"; buildInputs = [ oniguruma ]; }
|
||||
{ name = "mysqli"; configureFlags = [ "--with-mysqli=mysqlnd" "--with-mysql-sock=/run/mysqld/mysqld.sock" ]; }
|
||||
{ name = "mysqli";
|
||||
internalDeps = [ "mysqlnd" ];
|
||||
configureFlags = [ "--with-mysqli=mysqlnd" "--with-mysql-sock=/run/mysqld/mysqld.sock" ]; }
|
||||
{ name = "mysqlnd";
|
||||
buildInputs = [ zlib openssl ];
|
||||
# The configure script doesn't correctly add library link
|
||||
# flags, so we add them to the variable used by the Makefile
|
||||
# when linking.
|
||||
MYSQLND_SHARED_LIBADD = "-lssl -lcrypto -lz";
|
||||
# The configure script builds a config.h which is never
|
||||
# included. Let's include it in the main header file
|
||||
# included by all .c-files.
|
||||
patches = [
|
||||
(pkgs.writeText "mysqlnd_config.patch" ''
|
||||
--- a/mysqlnd.h
|
||||
+++ b/mysqlnd.h
|
||||
@@ -1,3 +1,6 @@
|
||||
+#ifdef HAVE_CONFIG_H
|
||||
+#include "config.h"
|
||||
+#endif
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) The PHP Group |
|
||||
'')
|
||||
];
|
||||
postPhpize = lib.optionalString (lib.versionOlder php.version "7.4") ''
|
||||
substituteInPlace configure --replace '$OPENSSL_LIBDIR' '${openssl}/lib' \
|
||||
--replace '$OPENSSL_INCDIR' '${openssl.dev}/include'
|
||||
''; }
|
||||
# oci8 (7.4, 7.3, 7.2)
|
||||
# odbc (7.4, 7.3, 7.2)
|
||||
{ name = "opcache"; buildInputs = [ pcre' ]; zendExtension = true; }
|
||||
{ name = "opcache";
|
||||
buildInputs = [ pcre' ];
|
||||
# HAVE_OPCACHE_FILE_CACHE is defined in config.h, which is
|
||||
# included from ZendAccelerator.h, but ZendAccelerator.h is
|
||||
# included after the ifdef...
|
||||
patches = lib.optional (lib.versionOlder php.version "7.4") [
|
||||
(pkgs.writeText "zend_file_cache_config.patch" ''
|
||||
--- a/zend_file_cache.c
|
||||
+++ b/zend_file_cache.c
|
||||
@@ -27,9 +27,9 @@
|
||||
#include "ext/standard/md5.h"
|
||||
#endif
|
||||
|
||||
+#include "ZendAccelerator.h"
|
||||
#ifdef HAVE_OPCACHE_FILE_CACHE
|
||||
|
||||
-#include "ZendAccelerator.h"
|
||||
#include "zend_file_cache.h"
|
||||
#include "zend_shared_alloc.h"
|
||||
#include "zend_accelerator_util_funcs.h"
|
||||
'') ];
|
||||
zendExtension = true; }
|
||||
{ name = "openssl";
|
||||
buildInputs = [ openssl ];
|
||||
configureFlags = [ "--with-openssl" ]; }
|
||||
{ name = "pcntl"; }
|
||||
{ name = "pdo"; }
|
||||
{ name = "pdo_dblib";
|
||||
internalDeps = [ "pdo" ];
|
||||
configureFlags = [ "--with-pdo-dblib=${freetds}" ];
|
||||
# Doesn't seem to work on darwin.
|
||||
enable = (!stdenv.isDarwin); }
|
||||
# pdo_firebird (7.4, 7.3, 7.2)
|
||||
{ name = "pdo_mysql"; configureFlags = [ "--with-pdo-mysql=mysqlnd" ]; }
|
||||
{ name = "pdo_mysql";
|
||||
internalDeps = [ "mysqlnd" "pdo" ];
|
||||
configureFlags = [ "--with-pdo-mysql=mysqlnd" ]; }
|
||||
# pdo_oci (7.4, 7.3, 7.2)
|
||||
{ name = "pdo_odbc"; configureFlags = [ "--with-pdo-odbc=unixODBC,${unixODBC}" ]; }
|
||||
{ name = "pdo_pgsql"; configureFlags = [ "--with-pdo-pgsql=${postgresql}" ]; }
|
||||
{ name = "pdo_sqlite"; buildInputs = [ sqlite ]; configureFlags = [ "--with-pdo-sqlite=${sqlite.dev}" ]; }
|
||||
{ name = "pgsql"; buildInputs = [ pcre' ]; configureFlags = [ "--with-pgsql=${postgresql}" ]; }
|
||||
{ name = "pdo_odbc";
|
||||
internalDeps = [ "pdo" ];
|
||||
configureFlags = [ "--with-pdo-odbc=unixODBC,${unixODBC}" ]; }
|
||||
{ name = "pdo_pgsql";
|
||||
internalDeps = [ "pdo" ];
|
||||
configureFlags = [ "--with-pdo-pgsql=${postgresql}" ]; }
|
||||
{ name = "pdo_sqlite";
|
||||
internalDeps = [ "pdo" ];
|
||||
buildInputs = [ sqlite ];
|
||||
configureFlags = [ "--with-pdo-sqlite=${sqlite.dev}" ]; }
|
||||
{ name = "pgsql";
|
||||
buildInputs = [ pcre' ];
|
||||
configureFlags = [ "--with-pgsql=${postgresql}" ]; }
|
||||
{ name = "posix"; }
|
||||
{ name = "pspell"; configureFlags = [ "--with-pspell=${aspell}" ]; }
|
||||
{ name = "recode";
|
||||
configureFlags = [ "--with-recode=${recode}" ];
|
||||
# Removed in php 7.4.
|
||||
enable = lib.versionOlder php.version "7.4"; }
|
||||
{ name = "readline";
|
||||
buildInputs = [ libedit readline ];
|
||||
configureFlags = [ "--with-readline=${readline.dev}" ];
|
||||
postPhpize = lib.optionalString (lib.versionOlder php.version "7.4") ''
|
||||
substituteInPlace configure --replace 'as_fn_error $? "Please reinstall libedit - I cannot find readline.h" "$LINENO" 5' ':'
|
||||
''; }
|
||||
# recode (7.3, 7.2)
|
||||
{ name = "session"; }
|
||||
{ name = "shmop"; }
|
||||
{ name = "simplexml";
|
||||
|
@ -846,6 +934,7 @@ let
|
|||
++ lib.optional (lib.versionOlder php.version "7.4") [ "--with-libxml-dir=${libxml2.dev}" ]; }
|
||||
{ name = "sockets"; }
|
||||
{ name = "sodium"; buildInputs = [ libsodium ]; }
|
||||
{ name = "sqlite3"; buildInputs = [ sqlite ]; }
|
||||
{ name = "sysvmsg"; }
|
||||
{ name = "sysvsem"; }
|
||||
{ name = "sysvshm"; }
|
||||
|
@ -853,6 +942,7 @@ let
|
|||
{ name = "tokenizer"; }
|
||||
{ name = "wddx";
|
||||
buildInputs = [ libxml2 ];
|
||||
internalDeps = [ "session" ];
|
||||
configureFlags = [ "--enable-wddx" "--with-libxml-dir=${libxml2.dev}" ];
|
||||
# Removed in php 7.4.
|
||||
enable = lib.versionOlder php.version "7.4"; }
|
||||
|
@ -882,6 +972,10 @@ let
|
|||
configureFlags = [ "--with-zip" ]
|
||||
++ lib.optional (lib.versionOlder php.version "7.4") [ "--with-zlib-dir=${zlib.dev}" ]
|
||||
++ lib.optional (lib.versionOlder php.version "7.3") [ "--with-libzip" ]; }
|
||||
{ name = "zlib";
|
||||
buildInputs = [ zlib ];
|
||||
configureFlags = [ "--with-zlib" ]
|
||||
++ lib.optional (lib.versionOlder php.version "7.4") [ "--with-zlib-dir=${zlib.dev}" ]; }
|
||||
];
|
||||
|
||||
# Convert the list of attrs:
|
||||
|
|
Loading…
Reference in a new issue