Skip to content

Commit

Permalink
php-master: init at 8.2.pre+date=20220426165801
Browse files Browse the repository at this point in the history
Co-Authored-By: Pol Dellaiera <pol.dellaiera@protonmail.com>
  • Loading branch information
jtojnar and drupol committed Apr 29, 2022
1 parent d602975 commit 7d8a440
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 32 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
strategy:
matrix:
php:
- branch: 'master'
- branch: '8.1'
- branch: '8.0'
- branch: '7.4'
Expand All @@ -40,9 +41,17 @@ 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 "::set-output name=major::$major"
echo "::set-output name=attr::$attr"
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ We use [Cachix](https://app.cachix.org/cache/fossar) to store `x86_64-linux` bin

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).

The following versions are currently supported:
The following versions are currently available:

- `php56`
- `php70`
Expand All @@ -24,6 +24,7 @@ The following versions are currently supported:
- `php74`
- `php80`
- `php81`
- `php-master`

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.

32 changes: 32 additions & 0 deletions pkgs/package-overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ prev:
let
patchName = patch: patch.name or (builtins.baseNameOf patch);
inherit (pkgs) lib;

isBuiltFromGit = lib.hasInfix "+date=" prev.php.version;
in

{
Expand All @@ -30,6 +32,29 @@ in
composer = final.callPackage ./composer/2.2.nix { };
};

# TODO: Address this in Nixpkgs.
mkExtension =
if lib.hasInfix "+date=" prev.php.version
then
attrs:

(prev.mkExtension attrs).overrideAttrs (attrs: {
# PHP obtained from Git contains files directly in the top-level directory,
# which will be placed in Nix store. The generic builder will then copy it
# to the /build sandbox as its basename with hash stripped (e.g. source/).
# `mkExtension` expects that PHP source will be extracted into `php-«version»/`
# directory like the tarball does and sets sourceRoot accordingly.
# Let’s unset the `sourceRoot`, leaving it to `unpackPhase` to find the source
# directory, and only change to the extension directory afterwards.
sourceRoot = null;
prePatch = ''
cd "${lib.removePrefix "php-${prev.php.version}/" attrs.sourceRoot}"
'' + attrs.prePatch;
})
else
prev.mkExtension;


extensions = prev.extensions // {
apcu =
if lib.versionOlder prev.php.version "7.0" then
Expand Down Expand Up @@ -319,6 +344,13 @@ in
ourPatches ++ upstreamPatches;
});

tokenizer =
prev.extensions.tokenizer.overrideAttrs (attrs: {
nativeBuildInputs = attrs.nativeBuildInputs or [ ] ++ lib.optionals isBuiltFromGit [
pkgs.bison
];
});

xdebug =
# xdebug versions were determined using https://xdebug.org/docs/compat
if lib.versionAtLeast prev.php.version "7.2" then
Expand Down
142 changes: 115 additions & 27 deletions pkgs/phps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ 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 @@ -23,34 +26,44 @@ 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:

{
patches =
let
upstreamPatches =
attrs.patches or [ ];

ourPatches =
prev.lib.optionals (prev.lib.versions.majorMinor args.version == "7.2") [
# Building the bundled intl extension fails on Mac OS.
# See https://bugs.php.net/bug.php?id=76826 for more information.
(prev.pkgs.fetchpatch {
url = "https://bugs.php.net/patch-display.php?bug_id=76826&patch=bug76826.poc.0.patch&revision=1538723399&download=1";
sha256 = "aW+MW9Kb8N/yBO7MdqZMZzgMSF7b+IMLulJKgKPWrUA=";
})
let
commonOverrides =
attrs:

{
patches =
let
upstreamPatches =
attrs.patches or [ ];

ourPatches =
prev.lib.optionals (prev.lib.versions.majorMinor args.version == "7.2") [
# Building the bundled intl extension fails on Mac OS.
# See https://bugs.php.net/bug.php?id=76826 for more information.
(prev.pkgs.fetchpatch {
url = "https://bugs.php.net/patch-display.php?bug_id=76826&patch=bug76826.poc.0.patch&revision=1538723399&download=1";
sha256 = "aW+MW9Kb8N/yBO7MdqZMZzgMSF7b+IMLulJKgKPWrUA=";
})
];
in
ourPatches ++ upstreamPatches;

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"
];
in
ourPatches ++ upstreamPatches;
};

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"
];
};
versionSpecificOverrides = args.phpAttrsOverrides or (attrs: { });
in
composeOverrides commonOverrides versionSpecificOverrides;

# For passing pcre2 to php-packages.nix.
callPackage =
Expand All @@ -72,7 +85,7 @@ let
else prev.pcre;
});
});
} // args;
};

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

Expand Down Expand Up @@ -115,6 +128,29 @@ let
})
];
});

base-master =
prev.callPackage generic (_mkArgs {
version =
let
configureFile = "${php-src}/configure.ac";
versionMatch = builtins.match ".*AC_INIT\\(\\[PHP],\\[(.+)-dev].*" (builtins.readFile configureFile);
version =
if builtins.pathExists configureFile && builtins.length versionMatch == 1
then builtins.head versionMatch
else "0.0.0+unknown";
in
"${version}.pre+date=${php-src.lastModifiedDate}";
sha256 = null;

phpAttrsOverrides = attrs: {
src = php-src;
configureFlags = attrs.configureFlags ++ [
# install-pear-nozlib.phar (normally shipped in tarball) would need to be downloaded.
"--without-pear"
];
};
});
in
{
php56 =
Expand Down Expand Up @@ -393,4 +429,56 @@ in
prev.php81.override {
inherit packageOverrides;
};

php-master =
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
])
);
}

0 comments on commit 7d8a440

Please sign in to comment.