unit: add php 8.1

Izorkin 2d7c97f4 66b6475a

Changed files
+17 -7
nixos
tests
web-servers
pkgs
servers
http
+11 -6
nixos/tests/web-servers/unit-php.nix
···
services.unit = {
enable = true;
config = pkgs.lib.strings.toJSON {
-
listeners."*:9080".application = "php_80";
-
applications.php_80 = {
-
type = "php 8.0";
processes = 1;
user = "testuser";
group = "testgroup";
root = "${testdir}/www";
index = "info.php";
-
options.file = "${pkgs.unit.usedPhp80}/lib/php.ini";
};
};
};
···
};
};
testScript = ''
machine.wait_for_unit("unit.service")
# 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"
# 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"
'';
})
···
services.unit = {
enable = true;
config = pkgs.lib.strings.toJSON {
+
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.usedPhp81}/lib/php.ini";
};
};
};
···
};
};
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: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()
'';
})
+6 -1
pkgs/servers/http/unit/default.nix
···
{ lib, stdenv, fetchFromGitHub, nixosTests, which
, pcre2
, withPython3 ? true, python3, ncurses
-
, withPHP80 ? true, php80
, withPerl532 ? false, perl532
, withPerl534 ? true, perl534
, withPerldevel ? false, perldevel
···
};
php80-unit = php80.override phpConfig;
in stdenv.mkDerivation rec {
version = "1.27.0";
···
buildInputs = [ pcre2.dev ]
++ optionals withPython3 [ python3 ncurses ]
++ optional withPHP80 php80-unit
++ optional withPerl532 perl532
++ optional withPerl534 perl534
++ optional withPerldevel perldevel
···
# Optionally add the PHP derivations used so they can be addressed in the configs
usedPhp80 = optionals withPHP80 php80-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 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"}
···
{ lib, stdenv, fetchFromGitHub, nixosTests, which
, pcre2
, withPython3 ? true, python3, ncurses
+
, withPHP80 ? false, php80
+
, withPHP81 ? true, php81
, withPerl532 ? false, perl532
, withPerl534 ? true, perl534
, withPerldevel ? false, perldevel
···
};
php80-unit = php80.override phpConfig;
+
php81-unit = php81.override phpConfig;
in stdenv.mkDerivation rec {
version = "1.27.0";
···
buildInputs = [ pcre2.dev ]
++ optionals withPython3 [ python3 ncurses ]
++ optional withPHP80 php80-unit
+
++ optional withPHP81 php81-unit
++ optional withPerl532 perl532
++ optional withPerl534 perl534
++ optional withPerldevel perldevel
···
# 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"}