Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php-master: init at php-8.4.0.snapshot.c803402-20230907122631 #104

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
strategy:
matrix:
php:
- branch: 'master'
- branch: '8.3'
- branch: '8.2'
- branch: '8.1'
Expand Down Expand Up @@ -49,9 +50,18 @@ jobs:
id: params
run: |
branch=${{ matrix.php.branch }}
major=${branch%%.*}
minor=${branch#*.}
attr=php$major$minor
if [[ "$branch" = "master" ]]; then
attr=php-master
version=$(nix-instantiate --eval --json -A "outputs.packages.x86_64-linux.${attr}.version")
# Strip quotes
version=${version//\"/}
major=${branch%%.*}
else
major=${branch%%.*}
minor=${branch#*.}
attr=php$major$minor
fi

echo "minor=$minor" >> $GITHUB_OUTPUT
echo "major=$major" >> $GITHUB_OUTPUT
echo "attr=$attr" >> $GITHUB_OUTPUT
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The following versions are currently available:
- `php81`
- `php82`
- `php83`
- `php-master` (updated weekly)

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

Expand Down
2 changes: 1 addition & 1 deletion checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}:

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

checks = {
php = {
Expand Down
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@

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

php-src = {
url = "github:php/php-src";
flake = false;
};

utils.url = "github:numtide/flake-utils";
};

outputs = { self, flake-compat, nixpkgs, utils }:
outputs = { self, flake-compat, nixpkgs, php-src, utils }:
# For each supported platform,
utils.lib.eachDefaultSystem (system:
let
Expand All @@ -29,14 +34,16 @@
};
in rec {
packages = {
inherit (pkgs) php php56 php70 php71 php72 php73 php74 php80 php81 php82 php83;
inherit (pkgs) php php56 php70 php71 php72 php73 php74 php80 php81 php82 php83 php-master;
};

checks = import ./checks.nix {
inherit packages pkgs system;
};
}
) // {
overlays.default = import ./pkgs/phps.nix nixpkgs.outPath;
overlays.default = import ./pkgs/phps.nix {
inherit nixpkgs php-src;
};
};
}
11 changes: 10 additions & 1 deletion pkgs/package-overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,16 @@ in

xdebug =
# xdebug versions were determined using https://xdebug.org/docs/compat
if lib.versionAtLeast prev.php.version "8.0" then
if lib.versionAtLeast prev.php.version "8.3" then
prev.extensions.xdebug.overrideAttrs (attrs: {
name = "xdebug-3.3.0alpha2";
version = "3.3.0alpha2";
src = pkgs.fetchurl {
url = "http://pecl.php.net/get/xdebug-3.3.0alpha2.tgz";
hash = "sha256-wcV71/taOpqs2ckX4vZT1TOWpl1JiP2s6EgPyX9EI6c=";
};
})
else if lib.versionAtLeast prev.php.version "8.0" then
prev.extensions.xdebug
else if lib.versionAtLeast prev.php.version "7.2" then
prev.extensions.xdebug.overrideAttrs (attrs: {
Expand Down
100 changes: 100 additions & 0 deletions pkgs/php/master.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{ prev
, generic
, _mkArgs
, php-src
}:

let
pear = prev.fetchurl {
url = "https://pear.php.net/install-pear-nozlib.phar";
hash = "sha256-UblKVcsm030tNSA6mdeab+h7ZhANNz7MkFf4Z1iigjs=";
};

base-master = prev.callPackage generic (_mkArgs {
hash = null;

version =
let
configureFile = "${php-src}/configure.ac";

extractVersionFromConfigureAc = configureText:
let
match = builtins.match ".*AC_INIT\\(\\[PHP],\\[([^]-]+)(-dev)?].*" configureText;
in
if match != null then builtins.head match else null;

extractVersionFromConfigureAcPre74 = configureText:
let
match = builtins.match ".*PHP_MAJOR_VERSION=([0-9]+)\nPHP_MINOR_VERSION=([0-9]+)\nPHP_RELEASE_VERSION=([0-9]+)\n.*" configureText;
in
if match != null then prev.lib.concatMapStringsSep "." builtins.toString match else null;

version =
let
configureText = builtins.readFile configureFile;
version = extractVersionFromConfigureAc configureText;
versionPre74 = extractVersionFromConfigureAcPre74 configureText;

versionCandidates = prev.lib.optionals (builtins.pathExists configureFile) [
version
versionPre74
];
in
prev.lib.findFirst (version: version != null) "0.0.0+unknown" versionCandidates;
in
"${version}.snapshot.${php-src.shortRev}-${php-src.lastModifiedDate}";

phpAttrsOverrides = attrs: {
src = php-src;

preInstall = attrs.preInstall or "" + ''
cp -f ${pear} ./pear/install-pear-nozlib.phar
'';
};
});
in
base-master.withExtensions ({ all, ... }: with all; [
bcmath
calendar
curl
ctype
dom
exif
fileinfo
filter
ftp
gd
gettext
gmp
iconv
intl
ldap
mbstring
mysqli
mysqlnd
opcache
openssl
pcntl
pdo
pdo_mysql
pdo_odbc
pdo_pgsql
pdo_sqlite
pgsql
posix
readline
session
simplexml
sockets
soap
sodium
sqlite3
tokenizer
xmlreader
xmlwriter
zip
zlib
]
++ prev.lib.optionals (!prev.stdenv.isDarwin) [
imap
])
71 changes: 44 additions & 27 deletions pkgs/phps.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
nixpkgs:
{
nixpkgs,
php-src,
}:

# These are older versions of PHP removed from Nixpkgs.

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

/* Composes package overrides (i.e. overlays that only take prev). */
composeOverrides = a: b: prev.lib.composeExtensions (_: a) (_: b) { };

_mkArgs =
args:

{
args
// {
inherit packageOverrides;

# For passing pcre2 to generic.nix.
Expand All @@ -20,8 +27,14 @@ let
then prev.pcre2
else prev.pcre;

# Overrides attributes passed to the stdenv.mkDerivation for the unwrapped PHP
# in <nixpkgs/pkgs/development/interpreters/php/generic.nix>.
# This will essentially end up creating a derivation equivalent to the following:
# stdenv.mkDerivation (versionSpecificOverrides (commonOverrides { /* stuff passed to mkDerivation in generic.nix */ }))
phpAttrsOverrides =
attrs:
let
commonOverrides =
attrs:

{
patches =
Expand All @@ -46,14 +59,13 @@ let
})
];

configureFlags =
attrs.configureFlags
++ prev.lib.optionals (prev.lib.versionOlder args.version "7.4") [
# phar extension’s build system expects hash or it will degrade.
"--enable-hash"

"--enable-libxml"
"--with-libxml-dir=${prev.libxml2.dev}"
configureFlags =
attrs.configureFlags
++ prev.lib.optionals (prev.lib.versionOlder args.version "7.4") [
# phar extension’s build system expects hash or it will degrade.
"--enable-hash"
"--enable-libxml"
"--with-libxml-dir=${prev.libxml2.dev}"
]
++ prev.lib.optionals (prev.lib.versions.majorMinor args.version == "7.3") [
# Force use of pkg-config.
Expand All @@ -72,20 +84,24 @@ let
prev.libxcrypt
];

preConfigure =
prev.lib.optionalString (prev.lib.versionOlder args.version "7.4") ''
# Workaround “configure: error: Your system does not support systemd.”
# caused by PHP build system expecting PKG_CONFIG variable to contain
# an absolute path on PHP ≤ 7.4.
# Also patches acinclude.m4, which ends up being used by extensions.
# https://github.com/NixOS/nixpkgs/pull/90249
for i in $(find . -type f -name "*.m4"); do
substituteInPlace $i \
--replace 'test -x "$PKG_CONFIG"' 'type -P "$PKG_CONFIG" >/dev/null'
done
''
+ attrs.preConfigure;
};
preConfigure =
prev.lib.optionalString (prev.lib.versionOlder args.version "7.4") ''
# Workaround “configure: error: Your system does not support systemd.”
# caused by PHP build system expecting PKG_CONFIG variable to contain
# an absolute path on PHP ≤ 7.4.
# Also patches acinclude.m4, which ends up being used by extensions.
# https://github.com/NixOS/nixpkgs/pull/90249
for i in $(find . -type f -name "*.m4"); do
substituteInPlace $i \
--replace 'test -x "$PKG_CONFIG"' 'type -P "$PKG_CONFIG" >/dev/null'
done
''
+ attrs.preConfigure;
};

versionSpecificOverrides = args.phpAttrsOverrides or (attrs: { });
in
composeOverrides commonOverrides versionSpecificOverrides;

# For passing pcre2 to php-packages.nix.
callPackage =
Expand Down Expand Up @@ -117,8 +133,7 @@ let
);
}
);
}
// args;
};

generic = "${nixpkgs}/pkgs/development/interpreters/php/generic.nix";
mkPhp = args: prev.callPackage generic (_mkArgs args);
Expand Down Expand Up @@ -149,4 +164,6 @@ in
php83 = prev.php83.override {
inherit packageOverrides;
};

php-master = import ./php/master.nix { inherit prev generic _mkArgs php-src; };
}