3
0
Fork 0
forked from mirrors/nixpkgs

unit: add php 8.1

This commit is contained in:
Izorkin 2022-06-03 09:27:57 +03:00
parent 66b6475aa8
commit 2d7c97f439
No known key found for this signature in database
GPG key ID: 1436C1B3F3679F09
2 changed files with 17 additions and 7 deletions

View file

@ -10,15 +10,15 @@ in {
services.unit = {
enable = true;
config = pkgs.lib.strings.toJSON {
listeners."*:9080".application = "php_80";
applications.php_80 = {
type = "php 8.0";
listeners."*:9081".application = "php_81";
applications.php_81 = {
type = "php 8.1";
processes = 1;
user = "testuser";
group = "testgroup";
root = "${testdir}/www";
index = "info.php";
options.file = "${pkgs.unit.usedPhp80}/lib/php.ini";
options.file = "${pkgs.unit.usedPhp81}/lib/php.ini";
};
};
};
@ -34,14 +34,19 @@ in {
};
};
testScript = ''
machine.start()
machine.wait_for_unit("unit.service")
machine.wait_for_open_port(9081)
# Check so we get an evaluated PHP back
response = machine.succeed("curl -f -vvv -s http://127.0.0.1:9080/")
assert "PHP Version ${pkgs.unit.usedPhp80.version}" in response, "PHP version not detected"
response = machine.succeed("curl -f -vvv -s http://127.0.0.1:9081/")
assert "PHP Version ${pkgs.unit.usedPhp81.version}" in response, "PHP version not detected"
# Check so we have database and some other extensions loaded
for ext in ["json", "opcache", "pdo_mysql", "pdo_pgsql", "pdo_sqlite"]:
assert ext in response, f"Missing {ext} extension"
machine.shutdown()
'';
})

View file

@ -1,7 +1,8 @@
{ lib, stdenv, fetchFromGitHub, nixosTests, which
, pcre2
, withPython3 ? true, python3, ncurses
, withPHP80 ? true, php80
, withPHP80 ? false, php80
, withPHP81 ? true, php81
, withPerl532 ? false, perl532
, withPerl534 ? true, perl534
, withPerldevel ? false, perldevel
@ -24,6 +25,7 @@ let
};
php80-unit = php80.override phpConfig;
php81-unit = php81.override phpConfig;
in stdenv.mkDerivation rec {
version = "1.27.0";
@ -41,6 +43,7 @@ in stdenv.mkDerivation rec {
buildInputs = [ pcre2.dev ]
++ optionals withPython3 [ python3 ncurses ]
++ optional withPHP80 php80-unit
++ optional withPHP81 php81-unit
++ optional withPerl532 perl532
++ optional withPerl534 perl534
++ optional withPerldevel perldevel
@ -58,10 +61,12 @@ in stdenv.mkDerivation rec {
# Optionally add the PHP derivations used so they can be addressed in the configs
usedPhp80 = optionals withPHP80 php80-unit;
usedPhp81 = optionals withPHP81 php81-unit;
postConfigure = ''
${optionalString withPython3 "./configure python --module=python3 --config=python3-config --lib-path=${python3}/lib"}
${optionalString withPHP80 "./configure php --module=php80 --config=${php80-unit.unwrapped.dev}/bin/php-config --lib-path=${php80-unit}/lib"}
${optionalString withPHP81 "./configure php --module=php81 --config=${php81-unit.unwrapped.dev}/bin/php-config --lib-path=${php81-unit}/lib"}
${optionalString withPerl532 "./configure perl --module=perl532 --perl=${perl532}/bin/perl"}
${optionalString withPerl534 "./configure perl --module=perl534 --perl=${perl534}/bin/perl"}
${optionalString withPerldevel "./configure perl --module=perldev --perl=${perldevel}/bin/perl"}