Skip to content

Commit 68f974a

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 68f974a

File tree

7 files changed

+154
-34
lines changed

7 files changed

+154
-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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ let
2020
inherit (pkgs) lib;
2121

2222
inherit (import ./lib.nix { inherit lib; }) removeLines;
23+
24+
isBuiltFromGit = lib.hasInfix "+date=" prev.php.version;
2325
in
2426

2527
{
@@ -706,6 +708,22 @@ in
706708
(attrs.patches or []);
707709
});
708710

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

pkgs/phps.nix

Lines changed: 94 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,56 @@ in
149164
php83 = prev.php83.override {
150165
inherit packageOverrides;
151166
};
167+
168+
php-master = base-master.withExtensions (
169+
{ all, ... }:
170+
171+
with all; (
172+
[
173+
bcmath
174+
calendar
175+
curl
176+
ctype
177+
dom
178+
exif
179+
fileinfo
180+
filter
181+
ftp
182+
gd
183+
gettext
184+
gmp
185+
iconv
186+
intl
187+
ldap
188+
mbstring
189+
mysqli
190+
mysqlnd
191+
opcache
192+
openssl
193+
pcntl
194+
pdo
195+
pdo_mysql
196+
pdo_odbc
197+
pdo_pgsql
198+
pdo_sqlite
199+
pgsql
200+
posix
201+
readline
202+
session
203+
simplexml
204+
sockets
205+
soap
206+
sodium
207+
sqlite3
208+
tokenizer
209+
xmlreader
210+
xmlwriter
211+
zip
212+
zlib
213+
]
214+
++ prev.lib.optionals (!prev.stdenv.isDarwin) [
215+
imap
216+
]
217+
)
218+
);
152219
}

0 commit comments

Comments
 (0)