Skip to content

Commit d8ea63d

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

File tree

8 files changed

+212
-34
lines changed

8 files changed

+212
-34
lines changed

.github/workflows/build.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
php:
19+
- branch: 'master'
1920
- branch: '8.3'
2021
- branch: '8.2'
2122
- branch: '8.1'
@@ -49,9 +50,18 @@ jobs:
4950
id: params
5051
run: |
5152
branch=${{ matrix.php.branch }}
52-
major=${branch%%.*}
53-
minor=${branch#*.}
54-
attr=php$major$minor
53+
if [[ "$branch" = "master" ]]; then
54+
attr=php-master
55+
version=$(nix-instantiate --eval --json -A "outputs.packages.x86_64-linux.${attr}.version")
56+
# Strip quotes
57+
version=${version//\"/}
58+
major=${branch%%.*}
59+
else
60+
major=${branch%%.*}
61+
minor=${branch#*.}
62+
attr=php$major$minor
63+
fi
64+
5565
echo "minor=$minor" >> $GITHUB_OUTPUT
5666
echo "major=$major" >> $GITHUB_OUTPUT
5767
echo "attr=$attr" >> $GITHUB_OUTPUT

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ The following versions are currently available:
2626
- `php81`
2727
- `php82`
2828
- `php83`
29+
- `php-master` (updated weekly)
2930

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

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.

flake.nix

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@
1010

1111
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
1212

13+
php-src = {
14+
url = "github:php/php-src";
15+
flake = false;
16+
};
17+
1318
utils.url = "github:numtide/flake-utils";
1419
};
1520

16-
outputs = { self, flake-compat, nixpkgs, utils }:
21+
outputs = { self, flake-compat, nixpkgs, php-src, utils }:
1722
# For each supported platform,
1823
utils.lib.eachDefaultSystem (system:
1924
let
@@ -29,14 +34,16 @@
2934
};
3035
in rec {
3136
packages = {
32-
inherit (pkgs) php php56 php70 php71 php72 php73 php74 php80 php81 php82 php83;
37+
inherit (pkgs) php php56 php70 php71 php72 php73 php74 php80 php81 php82 php83 php-master;
3338
};
3439

3540
checks = import ./checks.nix {
3641
inherit packages pkgs system;
3742
};
3843
}
3944
) // {
40-
overlays.default = import ./pkgs/phps.nix nixpkgs.outPath;
45+
overlays.default = import ./pkgs/phps.nix {
46+
inherit nixpkgs php-src;
47+
};
4148
};
4249
}

pkgs/package-overrides.nix

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,22 @@ in
706706
(attrs.patches or []);
707707
});
708708

709+
tokenizer = prev.extensions.tokenizer.overrideAttrs (attrs: {
710+
patches = builtins.filter
711+
(patch:
712+
# The patch do not apply to PHP < 8.1
713+
patchName patch == "fix-tokenizer-php81.patch" -> lib.versionAtLeast prev.php.version "8.1"
714+
)
715+
(attrs.patches or []);
716+
717+
nativeBuildInputs = attrs.nativeBuildInputs or [ ] ++ lib.optionals isBuiltFromGit [
718+
# Tarballs ship pre-generated parser files.
719+
pkgs.bison
720+
pkgs.flex
721+
];
722+
723+
});
724+
709725
wddx =
710726
if lib.versionOlder prev.php.version "7.4" then
711727
prev.mkExtension {

pkgs/php/master.nix

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
prev
3+
, generic
4+
, _mkArgs
5+
, php-src
6+
}:
7+
8+
let
9+
pear = prev.fetchurl {
10+
url = "https://pear.php.net/install-pear-nozlib.phar";
11+
hash = "sha256-UblKVcsm030tNSA6mdeab+h7ZhANNz7MkFf4Z1iigjs=";
12+
};
13+
14+
base-master = prev.callPackage generic (_mkArgs {
15+
version =
16+
let
17+
configureFile = "${php-src}/configure.ac";
18+
19+
extractVersionFromConfigureAc =
20+
configureText:
21+
22+
let
23+
match = builtins.match ".*AC_INIT\\(\\[PHP],\\[([^]-]+)(-dev)?].*" configureText;
24+
in
25+
if match != null
26+
then builtins.head match
27+
else null;
28+
29+
extractVersionFromConfigureAcPre74 =
30+
configureText:
31+
32+
let
33+
match = builtins.match ".*PHP_MAJOR_VERSION=([0-9]+)\nPHP_MINOR_VERSION=([0-9]+)\nPHP_RELEASE_VERSION=([0-9]+)\n.*" configureText;
34+
in
35+
if match != null
36+
then prev.lib.concatMapStringsSep "." builtins.toString match
37+
else null;
38+
39+
version =
40+
let
41+
configureText = builtins.readFile configureFile;
42+
version = extractVersionFromConfigureAc configureText;
43+
versionPre74 = extractVersionFromConfigureAcPre74 configureText;
44+
45+
versionCandidates = prev.lib.optionals (builtins.pathExists configureFile) [
46+
version
47+
versionPre74
48+
];
49+
in
50+
prev.lib.findFirst (version: version != null) "0.0.0+unknown" versionCandidates;
51+
in
52+
"${version}.snapshot.${php-src.shortRev}-${php-src.lastModifiedDate}";
53+
hash = null;
54+
55+
phpAttrsOverrides = attrs: {
56+
src = php-src;
57+
58+
postConfigure = ''
59+
cp -f ${pear} ./pear/install-pear-nozlib.phar
60+
'';
61+
};
62+
});
63+
in
64+
base-master.withExtensions ({ all, ... }:
65+
with all; [
66+
bcmath
67+
calendar
68+
curl
69+
ctype
70+
dom
71+
exif
72+
fileinfo
73+
filter
74+
ftp
75+
gd
76+
gettext
77+
gmp
78+
iconv
79+
intl
80+
ldap
81+
mbstring
82+
mysqli
83+
mysqlnd
84+
opcache
85+
openssl
86+
pcntl
87+
pdo
88+
pdo_mysql
89+
pdo_odbc
90+
pdo_pgsql
91+
pdo_sqlite
92+
pgsql
93+
posix
94+
readline
95+
session
96+
simplexml
97+
sockets
98+
soap
99+
sodium
100+
sqlite3
101+
tokenizer
102+
xmlreader
103+
xmlwriter
104+
zip
105+
zlib
106+
]
107+
++ prev.lib.optionals (!prev.stdenv.isDarwin) [
108+
imap
109+
]
110+
)

pkgs/phps.nix

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
nixpkgs:
1+
{
2+
nixpkgs,
3+
php-src,
4+
}:
25

36
# These are older versions of PHP removed from Nixpkgs.
47

@@ -8,10 +11,14 @@ prev:
811
let
912
packageOverrides = import ./package-overrides.nix prev;
1013

14+
/* Composes package overrides (i.e. overlays that only take prev). */
15+
composeOverrides = a: b: prev.lib.composeExtensions (_: a) (_: b) { };
16+
1117
_mkArgs =
1218
args:
1319

14-
{
20+
args
21+
// {
1522
inherit packageOverrides;
1623

1724
# For passing pcre2 to generic.nix.
@@ -20,8 +27,14 @@ let
2027
then prev.pcre2
2128
else prev.pcre;
2229

30+
# Overrides attributes passed to the stdenv.mkDerivation for the unwrapped PHP
31+
# in <nixpkgs/pkgs/development/interpreters/php/generic.nix>.
32+
# This will essentially end up creating a derivation equivalent to the following:
33+
# stdenv.mkDerivation (versionSpecificOverrides (commonOverrides { /* stuff passed to mkDerivation in generic.nix */ }))
2334
phpAttrsOverrides =
24-
attrs:
35+
let
36+
commonOverrides =
37+
attrs:
2538

2639
{
2740
patches =
@@ -46,14 +59,13 @@ let
4659
})
4760
];
4861

49-
configureFlags =
50-
attrs.configureFlags
51-
++ prev.lib.optionals (prev.lib.versionOlder args.version "7.4") [
52-
# phar extension’s build system expects hash or it will degrade.
53-
"--enable-hash"
54-
55-
"--enable-libxml"
56-
"--with-libxml-dir=${prev.libxml2.dev}"
62+
configureFlags =
63+
attrs.configureFlags
64+
++ prev.lib.optionals (prev.lib.versionOlder args.version "7.4") [
65+
# phar extension’s build system expects hash or it will degrade.
66+
"--enable-hash"
67+
"--enable-libxml"
68+
"--with-libxml-dir=${prev.libxml2.dev}"
5769
]
5870
++ prev.lib.optionals (prev.lib.versions.majorMinor args.version == "7.3") [
5971
# Force use of pkg-config.
@@ -72,20 +84,24 @@ let
7284
prev.libxcrypt
7385
];
7486

75-
preConfigure =
76-
prev.lib.optionalString (prev.lib.versionOlder args.version "7.4") ''
77-
# Workaround “configure: error: Your system does not support systemd.”
78-
# caused by PHP build system expecting PKG_CONFIG variable to contain
79-
# an absolute path on PHP ≤ 7.4.
80-
# Also patches acinclude.m4, which ends up being used by extensions.
81-
# https://github.com/NixOS/nixpkgs/pull/90249
82-
for i in $(find . -type f -name "*.m4"); do
83-
substituteInPlace $i \
84-
--replace 'test -x "$PKG_CONFIG"' 'type -P "$PKG_CONFIG" >/dev/null'
85-
done
86-
''
87-
+ attrs.preConfigure;
88-
};
87+
preConfigure =
88+
prev.lib.optionalString (prev.lib.versionOlder args.version "7.4") ''
89+
# Workaround “configure: error: Your system does not support systemd.”
90+
# caused by PHP build system expecting PKG_CONFIG variable to contain
91+
# an absolute path on PHP ≤ 7.4.
92+
# Also patches acinclude.m4, which ends up being used by extensions.
93+
# https://github.com/NixOS/nixpkgs/pull/90249
94+
for i in $(find . -type f -name "*.m4"); do
95+
substituteInPlace $i \
96+
--replace 'test -x "$PKG_CONFIG"' 'type -P "$PKG_CONFIG" >/dev/null'
97+
done
98+
''
99+
+ attrs.preConfigure;
100+
};
101+
102+
versionSpecificOverrides = args.phpAttrsOverrides or (attrs: { });
103+
in
104+
composeOverrides commonOverrides versionSpecificOverrides;
89105

90106
# For passing pcre2 to php-packages.nix.
91107
callPackage =
@@ -117,8 +133,7 @@ let
117133
);
118134
}
119135
);
120-
}
121-
// args;
136+
};
122137

123138
generic = "${nixpkgs}/pkgs/development/interpreters/php/generic.nix";
124139
mkPhp = args: prev.callPackage generic (_mkArgs args);
@@ -149,4 +164,6 @@ in
149164
php83 = prev.php83.override {
150165
inherit packageOverrides;
151166
};
167+
168+
php-master = import ./php/master.nix { inherit prev generic _mkArgs php-src; };
152169
}

0 commit comments

Comments
 (0)