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

Support old PHP versions #482

Open
wants to merge 1 commit into
base: main
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
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.

3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
url = "github:nix-community/pruned-racket-catalog/catalog";
flake = false;
};

# required for old PHP versions
phps.url = "github:fossar/nix-phps";
};

outputs = {
Expand Down
35 changes: 20 additions & 15 deletions src/subsystems/php/builders/granular-php/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
lib,
pkgs,
externals,
inputs,
...
}: {
type = "pure";
Expand Down Expand Up @@ -36,26 +37,30 @@

inherit (pkgs.callPackage ../../semver.nix {}) satisfies;

# php with required extensions
php =
if satisfies pkgs.php81.version subsystemAttrs.phpSemver
phpPackages = l.attrValues inputs.phps.packages.x86_64-linux;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
phpPackages = l.attrValues inputs.phps.packages.x86_64-linux;
phpPackages = l.attrValues inputs.phps.packages.x86_64-linux;
phpPackages = l.attrValues (import inputs.phps).packages.x86_64-linux;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my own understanding, what does import do here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of treating inputs.php like a flake, it treats it as a path and imports it. Currently we have a failing CI tests, because under some circumstances inputs.php is a path and not a flake. This is buggy behavior in our backward compat mechanism which I don't intend to fix anymore in favor of the upcoming v1 API changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably does not make much difference, maybe passing system attribute here instead of hard-coding x86_64-linux.

phpPackage = let
matchingVersions = l.filter (phpAttrs: satisfies phpAttrs.version subsystemAttrs.phpSemver) phpPackages;
in
if matchingVersions == []
then
pkgs.php81.withExtensions (
{
all,
enabled,
}:
l.unique (enabled
++ (l.attrValues (l.filterAttrs (e: _: l.elem e subsystemAttrs.phpExtensions) all)))
)
else
l.abort ''
Error: incompatible php versions.
Package "${defaultPackageName}" defines required php version:
"php": "${subsystemAttrs.phpSemver}"
Using php version "${pkgs.php81.version}" from attribute "pkgs.php81".
'';
composer = php.packages.composer;
No matching php version was found in known versions: ${toString (l.map (attrs: attrs.version) phpPackages)}.
''
else l.head matchingVersions;

# php with required extensions
php = phpPackage.withExtensions (
{
all,
enabled,
}:
l.unique (enabled
++ (l.attrValues (l.filterAttrs (e: _: l.elem e subsystemAttrs.phpExtensions) all)))
);
composer = phpPackage.packages.composer;

# packages to export
packages =
Expand Down
35 changes: 20 additions & 15 deletions src/subsystems/php/builders/simple-php/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
lib,
pkgs,
externals,
inputs,
...
}: {
type = "pure";
Expand Down Expand Up @@ -36,26 +37,30 @@

inherit (pkgs.callPackage ../../semver.nix {}) satisfies;

# php with required extensions
php =
if satisfies pkgs.php81.version subsystemAttrs.phpSemver
phpPackages = l.attrValues inputs.phps.packages.x86_64-linux;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
phpPackages = l.attrValues inputs.phps.packages.x86_64-linux;
phpPackages = l.attrValues inputs.phps.packages.x86_64-linux;
phpPackages = l.attrValues (import inputs.phps).packages.x86_64-linux;

phpPackage = let
matchingVersions = l.filter (phpAttrs: satisfies phpAttrs.version subsystemAttrs.phpSemver) phpPackages;
in
if matchingVersions == []
then
pkgs.php81.withExtensions (
{
all,
enabled,
}:
l.unique (enabled
++ (l.attrValues (l.filterAttrs (e: _: l.elem e subsystemAttrs.phpExtensions) all)))
)
else
l.abort ''
Error: incompatible php versions.
Package "${defaultPackageName}" defines required php version:
"php": "${subsystemAttrs.phpSemver}"
Using php version "${pkgs.php81.version}" from attribute "pkgs.php81".
'';
composer = php.packages.composer;
No matching php version was found in known versions: ${toString (l.map (attrs: attrs.version) phpPackages)}.
''
else l.head matchingVersions;

# php with required extensions
php = phpPackage.withExtensions (
{
all,
enabled,
}:
l.unique (enabled
++ (l.attrValues (l.filterAttrs (e: _: l.elem e subsystemAttrs.phpExtensions) all)))
);
composer = phpPackage.packages.composer;

# packages to export
packages =
Expand Down