@@ -11,10 +11,13 @@ prev:
1111let
1212 packageOverrides = import ./package-overrides.nix prev ;
1313
14+ /* Composes package overrides (i.e. overlays that only take prev). */
15+ composeOverrides = a : b : prev . lib . composeExtensions ( _ : a ) ( _ : b ) { } ;
16+
1417 _mkArgs =
1518 args :
1619
17- {
20+ args // {
1821 inherit packageOverrides ;
1922
2023 # For passing pcre2 to generic.nix.
2326 then prev . pcre2
2427 else prev . pcre ;
2528
29+ # Overrides attributes passed to the stdenv.mkDerivation for the unwrapped PHP
30+ # in <nixpkgs/pkgs/development/interpreters/php/generic.nix>.
31+ # This will essentially end up creating a derivation equivalent to the following:
32+ # stdenv.mkDerivation (versionSpecificOverrides (commonOverrides { /* stuff passed to mkDerivation in generic.nix */ }))
2633 phpAttrsOverrides =
27- attrs :
28-
29- {
30- patches =
31- let
32- upstreamPatches =
33- attrs . patches or [ ] ;
34-
35- ourPatches =
36- prev . lib . optionals ( prev . lib . versions . majorMinor args . version == "7.2" ) [
37- # Building the bundled intl extension fails on Mac OS.
38- # See https://bugs.php.net/bug.php?id=76826 for more information.
39- ( prev . pkgs . fetchpatch {
40- url = "https://bugs.php.net/patch-display.php?bug_id=76826&patch=bug76826.poc.0.patch&revision=1538723399&download=1" ;
41- sha256 = "aW+MW9Kb8N/yBO7MdqZMZzgMSF7b+IMLulJKgKPWrUA=" ;
42- } )
34+ let
35+ commonOverrides =
36+ attrs :
37+
38+ {
39+ patches =
40+ let
41+ upstreamPatches =
42+ attrs . patches or [ ] ;
43+
44+ ourPatches =
45+ prev . lib . optionals ( prev . lib . versions . majorMinor args . version == "7.2" ) [
46+ # Building the bundled intl extension fails on Mac OS.
47+ # See https://bugs.php.net/bug.php?id=76826 for more information.
48+ ( prev . pkgs . fetchpatch {
49+ url = "https://bugs.php.net/patch-display.php?bug_id=76826&patch=bug76826.poc.0.patch&revision=1538723399&download=1" ;
50+ sha256 = "aW+MW9Kb8N/yBO7MdqZMZzgMSF7b+IMLulJKgKPWrUA=" ;
51+ } )
52+ ] ;
53+ in
54+ ourPatches ++ upstreamPatches ;
55+
56+ configureFlags =
57+ attrs . configureFlags
58+ ++ prev . lib . optionals ( prev . lib . versionOlder args . version "7.4" ) [
59+ # phar extension’s build system expects hash or it will degrade.
60+ "--enable-hash"
4361 ] ;
44- in
45- ourPatches ++ upstreamPatches ;
62+ } ;
4663
47- configureFlags =
48- attrs . configureFlags
49- ++ prev . lib . optionals ( prev . lib . versionOlder args . version "7.4" ) [
50- # phar extension’s build system expects hash or it will degrade.
51- "--enable-hash"
52- ] ;
53- } ;
64+ versionSpecificOverrides = args . phpAttrsOverrides or ( attrs : { } ) ;
65+ in
66+ composeOverrides commonOverrides versionSpecificOverrides ;
5467
5568 # For passing pcre2 to php-packages.nix.
5669 callPackage =
7285 else prev . pcre ;
7386 } ) ;
7487 } ) ;
75- } // args ;
88+ } ;
7689
7790 generic = "${ nixpkgs } /pkgs/development/interpreters/php/generic.nix" ;
7891
115128 } )
116129 ] ;
117130 } ) ;
131+
132+ base-master =
133+ prev . callPackage generic ( _mkArgs {
134+ version =
135+ let
136+ configureFile = "${ php-src } /configure.ac" ;
137+
138+ extractVersionFromConfigureAc =
139+ configureText :
140+
141+ let
142+ match = builtins . match ".*AC_INIT\\ (\\ [PHP],\\ [([^]-]+)(-dev)?].*" configureText ;
143+ in
144+ if match != null
145+ then builtins . head match
146+ else null ;
147+
148+ extractVersionFromConfigureAcPre74 =
149+ configureText :
150+
151+ let
152+ match = builtins . match ".*PHP_MAJOR_VERSION=([0-9]+)\n PHP_MINOR_VERSION=([0-9]+)\n PHP_RELEASE_VERSION=([0-9]+)\n .*" configureText ;
153+ in
154+ if match != null
155+ then prev . lib . concatMapStringsSep "." builtins . toString match
156+ else null ;
157+
158+ version =
159+ let
160+ configureText = builtins . readFile configureFile ;
161+ version = extractVersionFromConfigureAc configureText ;
162+ versionPre74 = extractVersionFromConfigureAcPre74 configureText ;
163+
164+ versionCandidates = prev . lib . optionals ( builtins . pathExists configureFile ) [
165+ version
166+ versionPre74
167+ ] ;
168+ in
169+ prev . lib . findFirst ( version : version != null ) "0.0.0+unknown" versionCandidates ;
170+ in
171+ "${ version } .pre+date=${ php-src . lastModifiedDate } " ;
172+ sha256 = null ;
173+
174+ phpAttrsOverrides = attrs : {
175+ src = php-src ;
176+ configureFlags = attrs . configureFlags ++ [
177+ # install-pear-nozlib.phar (normally shipped in tarball) would need to be downloaded.
178+ "--without-pear"
179+ ] ;
180+ } ;
181+ } ) ;
118182in
119183{
120184 php56 =
393457 prev . php81 . override {
394458 inherit packageOverrides ;
395459 } ;
460+
461+ php-master =
462+ base-master . withExtensions
463+ (
464+ { all , ... } :
465+
466+ with all ;
467+ ( [
468+ bcmath
469+ calendar
470+ curl
471+ ctype
472+ dom
473+ exif
474+ fileinfo
475+ filter
476+ ftp
477+ gd
478+ gettext
479+ gmp
480+ iconv
481+ intl
482+ ldap
483+ mbstring
484+ mysqli
485+ mysqlnd
486+ opcache
487+ openssl
488+ pcntl
489+ pdo
490+ pdo_mysql
491+ pdo_odbc
492+ pdo_pgsql
493+ pdo_sqlite
494+ pgsql
495+ posix
496+ readline
497+ session
498+ simplexml
499+ sockets
500+ soap
501+ sodium
502+ sqlite3
503+ tokenizer
504+ xmlreader
505+ xmlwriter
506+ zip
507+ zlib
508+ ] ++ prev . lib . optionals ( ! prev . stdenv . isDarwin ) [
509+ imap
510+ ] )
511+ ) ;
396512}
0 commit comments