From c214e63f2e0dd81a9c03bdcbb83dbe8ddfd7d980 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 16 Apr 2020 22:52:52 +0200 Subject: [PATCH 1/5] nixos/httpd: Use extensions from php package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the recent rewrite, enabled extensions are passed to php programs through an extra ini file by a wrapper. Since httpd uses shared module instead of program, the wrapper did not affect it and no extensions other than built-ins were loaded. To fix this, we are passing the extension config another way – by adding it to the service's generated config. For now we are hardcoding the path to the ini file. It would be nice to add the path to the passthru and use that once the PHP expression settles down. --- nixos/modules/services/web-servers/apache-httpd/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/services/web-servers/apache-httpd/default.nix b/nixos/modules/services/web-servers/apache-httpd/default.nix index 832c8b30ee9d..faefd1bfd090 100644 --- a/nixos/modules/services/web-servers/apache-httpd/default.nix +++ b/nixos/modules/services/web-servers/apache-httpd/default.nix @@ -338,6 +338,7 @@ let } '' cat ${php}/etc/php.ini > $out + cat ${php}/lib/custom-php.ini > $out echo "$options" >> $out ''; From aac9832b96cb9e79348b6fc48da7b308ad9b8838 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 16 Apr 2020 21:48:40 +0200 Subject: [PATCH 2/5] nixosTests.php.httpd: init --- nixos/release-combined.nix | 1 + nixos/tests/php/default.nix | 1 + nixos/tests/php/httpd.nix | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 nixos/tests/php/httpd.nix diff --git a/nixos/release-combined.nix b/nixos/release-combined.nix index 02f19610f8a6..2a0a9113a86b 100644 --- a/nixos/release-combined.nix +++ b/nixos/release-combined.nix @@ -117,6 +117,7 @@ in rec { (onFullSupported "nixos.tests.openssh") (onFullSupported "nixos.tests.pantheon") (onFullSupported "nixos.tests.php.fpm") + (onFullSupported "nixos.tests.php.httpd") (onFullSupported "nixos.tests.php.pcre") (onFullSupported "nixos.tests.plasma5") (onFullSupported "nixos.tests.predictable-interface-names.predictableNetworkd") diff --git a/nixos/tests/php/default.nix b/nixos/tests/php/default.nix index 9ab14f722d08..ee7a3b56a3ef 100644 --- a/nixos/tests/php/default.nix +++ b/nixos/tests/php/default.nix @@ -3,5 +3,6 @@ pkgs ? import ../../.. { inherit system config; } }: { fpm = import ./fpm.nix { inherit system pkgs; }; + httpd = import ./httpd.nix { inherit system pkgs; }; pcre = import ./pcre.nix { inherit system pkgs; }; } diff --git a/nixos/tests/php/httpd.nix b/nixos/tests/php/httpd.nix new file mode 100644 index 000000000000..fc3ff986734e --- /dev/null +++ b/nixos/tests/php/httpd.nix @@ -0,0 +1,31 @@ +import ../make-test-python.nix ({pkgs, ...}: { + name = "php-httpd-test"; + meta.maintainers = with pkgs.stdenv.lib.maintainers; [ etu ]; + + machine = { config, lib, pkgs, ... }: { + services.httpd = { + enable = true; + adminAddr = "admin@phpfpm"; + virtualHosts."phpfpm" = let + testdir = pkgs.writeTextDir "web/index.php" " Date: Thu, 16 Apr 2020 23:19:45 +0200 Subject: [PATCH 3/5] nixosTests.php.pcre: Clean up And add assertion messages --- nixos/tests/php/pcre.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nixos/tests/php/pcre.nix b/nixos/tests/php/pcre.nix index 56a87778579f..016dca81d522 100644 --- a/nixos/tests/php/pcre.nix +++ b/nixos/tests/php/pcre.nix @@ -30,8 +30,8 @@ in import ../make-test-python.nix ({ ...}: { '' machine.wait_for_unit("httpd.service") # Ensure php evaluation by matching on the var_dump syntax - assert 'string(${toString (builtins.stringLength testString)}) "${testString}"' in machine.succeed( - "curl -vvv -s http://127.0.0.1:80/index.php" - ) + response = machine.succeed("curl -vvv -s http://127.0.0.1:80/index.php") + expected = 'string(${toString (builtins.stringLength testString)}) "${testString}"' + assert expected in response, "Does not appear to be able to use subgroups." ''; }) From 23a6903bb7f32068587a66af00404a5e81881215 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 16 Apr 2020 23:21:26 +0200 Subject: [PATCH 4/5] nixosTests.php.fpm: Clean up to match httpd test --- nixos/tests/php/fpm.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nixos/tests/php/fpm.nix b/nixos/tests/php/fpm.nix index e93a31834185..1e4ced24b6c3 100644 --- a/nixos/tests/php/fpm.nix +++ b/nixos/tests/php/fpm.nix @@ -43,13 +43,11 @@ import ../make-test-python.nix ({pkgs, ...}: { machine.wait_for_unit("phpfpm-foobar.service") # Check so we get an evaluated PHP back - assert "PHP Version ${pkgs.php.version}" in machine.succeed("curl -vvv -s http://127.0.0.1:80/") + response = machine.succeed("curl -vvv -s http://127.0.0.1:80/") + assert "PHP Version ${pkgs.php.version}" in response, "PHP version not detected" # Check so we have database and some other extensions loaded - assert "json" in machine.succeed("curl -vvv -s http://127.0.0.1:80/") - assert "opcache" in machine.succeed("curl -vvv -s http://127.0.0.1:80/") - assert "pdo_mysql" in machine.succeed("curl -vvv -s http://127.0.0.1:80/") - assert "pdo_pgsql" in machine.succeed("curl -vvv -s http://127.0.0.1:80/") - assert "pdo_sqlite" in machine.succeed("curl -vvv -s http://127.0.0.1:80/") + for ext in ["json", "opcache", "pdo_mysql", "pdo_pgsql", "pdo_sqlite"]: + assert ext in response, f"Missing {ext} extension" ''; }) From 4816b426a057df94f0533d783d3cf6a4c5607aa3 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 16 Apr 2020 23:14:28 +0200 Subject: [PATCH 5/5] nixos/httpd: remove unnecessary override This was introduced in https://github.com/NixOS/nixpkgs/commit/c801cd1a047efa51055fd04698e316ddd503fd1b but it no longer seems necessary. --- nixos/modules/services/web-servers/apache-httpd/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/web-servers/apache-httpd/default.nix b/nixos/modules/services/web-servers/apache-httpd/default.nix index faefd1bfd090..5e55baa203a0 100644 --- a/nixos/modules/services/web-servers/apache-httpd/default.nix +++ b/nixos/modules/services/web-servers/apache-httpd/default.nix @@ -12,7 +12,7 @@ let httpdConf = cfg.configFile; - php = cfg.phpPackage.override { apacheHttpd = pkg.dev; /* otherwise it only gets .out */ }; + php = cfg.phpPackage.override { apacheHttpd = pkg; }; phpMajorVersion = lib.versions.major (lib.getVersion php);