Skip to content

Commit 7d8a440

Browse files
jtojnardrupol
andcommitted
php-master: init at 8.2.pre+date=20220426165801
Co-Authored-By: Pol Dellaiera <pol.dellaiera@protonmail.com>
1 parent d602975 commit 7d8a440

File tree

6 files changed

+179
-32
lines changed

6 files changed

+179
-32
lines changed

.github/workflows/build.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
strategy:
1515
matrix:
1616
php:
17+
- branch: 'master'
1718
- branch: '8.1'
1819
- branch: '8.0'
1920
- branch: '7.4'
@@ -40,9 +41,17 @@ jobs:
4041
id: params
4142
run: |
4243
branch=${{ matrix.php.branch }}
43-
major=${branch%%.*}
44-
minor=${branch#*.}
45-
attr=php$major$minor
44+
if [[ "$branch" = "master" ]]; then
45+
attr=php-master
46+
version=$(nix-instantiate --eval --json -A "outputs.packages.x86_64-linux.${attr}.version")
47+
# Strip quotes
48+
version=${version//\"/}
49+
major=${branch%%.*}
50+
else
51+
major=${branch%%.*}
52+
minor=${branch#*.}
53+
attr=php$major$minor
54+
fi
4655
echo "::set-output name=major::$major"
4756
echo "::set-output name=attr::$attr"
4857

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ We use [Cachix](https://app.cachix.org/cache/fossar) to store `x86_64-linux` bin
1414

1515
This package is regularly updated to match latest Nixpkgs and the PHP packages use the [same API as those in Nixpkgs](https://nixos.org/manual/nixpkgs/unstable/#sec-php).
1616

17-
The following versions are currently supported:
17+
The following versions are currently available:
1818

1919
- `php56`
2020
- `php70`
@@ -24,6 +24,7 @@ The following versions are currently supported:
2424
- `php74`
2525
- `php80`
2626
- `php81`
27+
- `php-master`
2728

2829
There is also a `php` package which is the alias of the default PHP version in Nixpkgs.
2930

checks.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
}:
66

77
let
8-
phpPackages = builtins.filter (name: builtins.match "php[0-9]+" name != null) (builtins.attrNames packages);
8+
phpPackages = builtins.filter (name: builtins.match "php([0-9]+|-master)" name != null) (builtins.attrNames packages);
99

1010
checks = {
1111
php = {

flake.lock

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkgs/package-overrides.nix

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ prev:
99
let
1010
patchName = patch: patch.name or (builtins.baseNameOf patch);
1111
inherit (pkgs) lib;
12+
13+
isBuiltFromGit = lib.hasInfix "+date=" prev.php.version;
1214
in
1315

1416
{
@@ -30,6 +32,29 @@ in
3032
composer = final.callPackage ./composer/2.2.nix { };
3133
};
3234

35+
# TODO: Address this in Nixpkgs.
36+
mkExtension =
37+
if lib.hasInfix "+date=" prev.php.version
38+
then
39+
attrs:
40+
41+
(prev.mkExtension attrs).overrideAttrs (attrs: {
42+
# PHP obtained from Git contains files directly in the top-level directory,
43+
# which will be placed in Nix store. The generic builder will then copy it
44+
# to the /build sandbox as its basename with hash stripped (e.g. source/).
45+
# `mkExtension` expects that PHP source will be extracted into `php-«version»/`
46+
# directory like the tarball does and sets sourceRoot accordingly.
47+
# Let’s unset the `sourceRoot`, leaving it to `unpackPhase` to find the source
48+
# directory, and only change to the extension directory afterwards.
49+
sourceRoot = null;
50+
prePatch = ''
51+
cd "${lib.removePrefix "php-${prev.php.version}/" attrs.sourceRoot}"
52+
'' + attrs.prePatch;
53+
})
54+
else
55+
prev.mkExtension;
56+
57+
3358
extensions = prev.extensions // {
3459
apcu =
3560
if lib.versionOlder prev.php.version "7.0" then
@@ -319,6 +344,13 @@ in
319344
ourPatches ++ upstreamPatches;
320345
});
321346

347+
tokenizer =
348+
prev.extensions.tokenizer.overrideAttrs (attrs: {
349+
nativeBuildInputs = attrs.nativeBuildInputs or [ ] ++ lib.optionals isBuiltFromGit [
350+
pkgs.bison
351+
];
352+
});
353+
322354
xdebug =
323355
# xdebug versions were determined using https://xdebug.org/docs/compat
324356
if lib.versionAtLeast prev.php.version "7.2" then

pkgs/phps.nix

Lines changed: 115 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ prev:
1111
let
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.
@@ -23,34 +26,44 @@ let
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 =
@@ -72,7 +85,7 @@ let
7285
else prev.pcre;
7386
});
7487
});
75-
} // args;
88+
};
7689

7790
generic = "${nixpkgs}/pkgs/development/interpreters/php/generic.nix";
7891

@@ -115,6 +128,29 @@ let
115128
})
116129
];
117130
});
131+
132+
base-master =
133+
prev.callPackage generic (_mkArgs {
134+
version =
135+
let
136+
configureFile = "${php-src}/configure.ac";
137+
versionMatch = builtins.match ".*AC_INIT\\(\\[PHP],\\[(.+)-dev].*" (builtins.readFile configureFile);
138+
version =
139+
if builtins.pathExists configureFile && builtins.length versionMatch == 1
140+
then builtins.head versionMatch
141+
else "0.0.0+unknown";
142+
in
143+
"${version}.pre+date=${php-src.lastModifiedDate}";
144+
sha256 = null;
145+
146+
phpAttrsOverrides = attrs: {
147+
src = php-src;
148+
configureFlags = attrs.configureFlags ++ [
149+
# install-pear-nozlib.phar (normally shipped in tarball) would need to be downloaded.
150+
"--without-pear"
151+
];
152+
};
153+
});
118154
in
119155
{
120156
php56 =
@@ -393,4 +429,56 @@ in
393429
prev.php81.override {
394430
inherit packageOverrides;
395431
};
432+
433+
php-master =
434+
base-master.withExtensions
435+
(
436+
{ all, ... }:
437+
438+
with all;
439+
([
440+
bcmath
441+
calendar
442+
curl
443+
ctype
444+
dom
445+
exif
446+
fileinfo
447+
filter
448+
ftp
449+
gd
450+
gettext
451+
gmp
452+
iconv
453+
intl
454+
ldap
455+
mbstring
456+
mysqli
457+
mysqlnd
458+
opcache
459+
openssl
460+
pcntl
461+
pdo
462+
pdo_mysql
463+
pdo_odbc
464+
pdo_pgsql
465+
pdo_sqlite
466+
pgsql
467+
posix
468+
readline
469+
session
470+
simplexml
471+
sockets
472+
soap
473+
sodium
474+
sqlite3
475+
tokenizer
476+
xmlreader
477+
xmlwriter
478+
zip
479+
zlib
480+
] ++ prev.lib.optionals (!prev.stdenv.isDarwin) [
481+
imap
482+
])
483+
);
396484
}

0 commit comments

Comments
 (0)