From a081dcf86de4f100efe604a52b32df4b14892f44 Mon Sep 17 00:00:00 2001 From: Elis Hirwing Date: Sat, 27 Feb 2021 18:29:08 +0100 Subject: [PATCH 1/6] php: Add php package versions to extensions/packages pnames --- pkgs/build-support/build-pecl.nix | 4 ++-- pkgs/top-level/php-packages.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/build-pecl.nix b/pkgs/build-support/build-pecl.nix index d75d3cf943a0..bc905ee84a06 100644 --- a/pkgs/build-support/build-pecl.nix +++ b/pkgs/build-support/build-pecl.nix @@ -16,10 +16,10 @@ }@args: stdenv.mkDerivation (args // { - name = "php-${pname}-${version}"; + pname = "php-${php.version}-${pname}"; extensionName = pname; - inherit src; + inherit version src; nativeBuildInputs = [ autoreconfHook re2c ] ++ nativeBuildInputs; buildInputs = [ php ] ++ peclDeps ++ buildInputs; diff --git a/pkgs/top-level/php-packages.nix b/pkgs/top-level/php-packages.nix index c9c4414f2fbf..3c8738565f60 100644 --- a/pkgs/top-level/php-packages.nix +++ b/pkgs/top-level/php-packages.nix @@ -16,7 +16,7 @@ lib.makeScope pkgs.newScope (self: with self; { # Wrap mkDerivation to prepend pname with "php-" to make names consistent # with how buildPecl does it and make the file easier to overview. mkDerivation = { pname, ... }@args: pkgs.stdenv.mkDerivation (args // { - pname = "php-${pname}"; + pname = "php-${php.version}-${pname}"; }); pcre' = if (lib.versionAtLeast php.version "7.3") then pcre2 else pcre; From 367d58415c647d4a8839558c68ddfe5e866e10aa Mon Sep 17 00:00:00 2001 From: Elis Hirwing Date: Sat, 27 Feb 2021 18:34:55 +0100 Subject: [PATCH 2/6] php: Add missing comment and remove unnecessary version specifications --- pkgs/top-level/all-packages.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 55e10c5334a8..b13cfca87f6e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11380,9 +11380,10 @@ in # # Set default PHP interpreter, extensions and packages php = php74; - phpExtensions = php74Extensions; - phpPackages = php74Packages; + phpExtensions = php.extensions; + phpPackages = php.packages; + # Import PHP80 interpreter, extensions and packages php80 = callPackage ../development/interpreters/php/8.0.nix { stdenv = if stdenv.cc.isClang then llvmPackages_6.stdenv else stdenv; }; From ac8a8fe2fafa244b14f640083008464e37096c9b Mon Sep 17 00:00:00 2001 From: Elis Hirwing Date: Sat, 27 Feb 2021 18:36:45 +0100 Subject: [PATCH 3/6] php: Rename extra init file in store and symlink it instead of copying --- pkgs/development/interpreters/php/generic.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/interpreters/php/generic.nix b/pkgs/development/interpreters/php/generic.nix index 191d589aa90c..ec5f955370f3 100644 --- a/pkgs/development/interpreters/php/generic.nix +++ b/pkgs/development/interpreters/php/generic.nix @@ -5,7 +5,7 @@ let generic = - { callPackage, lib, stdenv, nixosTests, config, fetchurl, makeWrapper + { callPackage, lib, stdenv, nixosTests, fetchurl, makeWrapper , symlinkJoin, writeText, autoconf, automake, bison, flex, libtool , pkg-config, re2c, apacheHttpd, libargon2, libxml2, pcre, pcre2 , systemd, system-sendmail, valgrind, xcbuild @@ -97,7 +97,7 @@ let (enabledExtensions ++ (getDepsRecursively enabledExtensions))); extNames = map getExtName enabledExtensions; - extraInit = writeText "php.ini" '' + extraInit = writeText "php-extra-init-${version}.ini" '' ${lib.concatStringsSep "\n" (lib.textClosureList extensionTexts extNames)} ${extraConfig} @@ -121,7 +121,7 @@ let }; paths = [ php ]; postBuild = '' - cp ${extraInit} $out/lib/php.ini + ln -s ${extraInit} $out/lib/php.ini wrapProgram $out/bin/php --set PHP_INI_SCAN_DIR $out/lib From c6f0a1db39eae371e81c4c46541e59dce828580a Mon Sep 17 00:00:00 2001 From: Elis Hirwing Date: Sat, 27 Feb 2021 19:39:26 +0100 Subject: [PATCH 4/6] nixos/tests/php: Declare php package used instead of just using default --- nixos/tests/php/default.nix | 13 +++++++------ nixos/tests/php/fpm.nix | 7 ++++--- nixos/tests/php/httpd.nix | 7 ++++--- nixos/tests/php/pcre.nix | 5 +++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/nixos/tests/php/default.nix b/nixos/tests/php/default.nix index ee7a3b56a3ef..6ecaed246046 100644 --- a/nixos/tests/php/default.nix +++ b/nixos/tests/php/default.nix @@ -1,8 +1,9 @@ -{ system ? builtins.currentSystem, - config ? {}, - pkgs ? import ../../.. { inherit system config; } +{ system ? builtins.currentSystem +, config ? {} +, pkgs ? import ../../.. { inherit system config; } +, php ? pkgs.php }: { - fpm = import ./fpm.nix { inherit system pkgs; }; - httpd = import ./httpd.nix { inherit system pkgs; }; - pcre = import ./pcre.nix { inherit system pkgs; }; + fpm = import ./fpm.nix { inherit system pkgs php; }; + httpd = import ./httpd.nix { inherit system pkgs php; }; + pcre = import ./pcre.nix { inherit system pkgs php; }; } diff --git a/nixos/tests/php/fpm.nix b/nixos/tests/php/fpm.nix index 9ad515ebdde0..f84394ccea45 100644 --- a/nixos/tests/php/fpm.nix +++ b/nixos/tests/php/fpm.nix @@ -1,5 +1,5 @@ -import ../make-test-python.nix ({pkgs, lib, ...}: { - name = "php-fpm-nginx-test"; +import ../make-test-python.nix ({pkgs, lib, php, ...}: { + name = "php-${php.version}-fpm-nginx-test"; meta.maintainers = lib.teams.php.members; machine = { config, lib, pkgs, ... }: { @@ -25,6 +25,7 @@ import ../make-test-python.nix ({pkgs, lib, ...}: { services.phpfpm.pools."foobar" = { user = "nginx"; + phpPackage = php; settings = { "listen.group" = "nginx"; "listen.mode" = "0600"; @@ -44,7 +45,7 @@ import ../make-test-python.nix ({pkgs, lib, ...}: { # Check so we get an evaluated PHP back response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/") - assert "PHP Version ${pkgs.php.version}" in response, "PHP version not detected" + assert "PHP Version ${php.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"]: diff --git a/nixos/tests/php/httpd.nix b/nixos/tests/php/httpd.nix index 27ea7a24e3a9..a5ca9b3c5d1f 100644 --- a/nixos/tests/php/httpd.nix +++ b/nixos/tests/php/httpd.nix @@ -1,5 +1,5 @@ -import ../make-test-python.nix ({pkgs, lib, ...}: { - name = "php-httpd-test"; +import ../make-test-python.nix ({pkgs, lib, php, ...}: { + name = "php-${php.version}-httpd-test"; meta.maintainers = lib.teams.php.members; machine = { config, lib, pkgs, ... }: { @@ -14,6 +14,7 @@ import ../make-test-python.nix ({pkgs, lib, ...}: { index = "index.php index.html"; }; }; + phpPackage = php; enablePHP = true; }; }; @@ -22,7 +23,7 @@ import ../make-test-python.nix ({pkgs, lib, ...}: { # Check so we get an evaluated PHP back response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/") - assert "PHP Version ${pkgs.php.version}" in response, "PHP version not detected" + assert "PHP Version ${php.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"]: diff --git a/nixos/tests/php/pcre.nix b/nixos/tests/php/pcre.nix index 3ea19304bffd..97572f63af33 100644 --- a/nixos/tests/php/pcre.nix +++ b/nixos/tests/php/pcre.nix @@ -1,7 +1,7 @@ let testString = "can-use-subgroups"; -in import ../make-test-python.nix ({lib, ...}: { - name = "php-httpd-pcre-jit-test"; +in import ../make-test-python.nix ({lib, php, ...}: { + name = "php-${php.version}-httpd-pcre-jit-test"; meta.maintainers = lib.teams.php.members; machine = { lib, pkgs, ... }: { @@ -9,6 +9,7 @@ in import ../make-test-python.nix ({lib, ...}: { services.httpd = { enable = true; adminAddr = "please@dont.contact"; + phpPackage = php; enablePHP = true; phpOptions = "pcre.jit = true"; extraConfig = let From 1216baaee11d203b857baeb5808d4220a1774068 Mon Sep 17 00:00:00 2001 From: Elis Hirwing Date: Sat, 27 Feb 2021 21:40:00 +0100 Subject: [PATCH 5/6] nixos/httpd: Fix httpd module for php8 --- nixos/modules/services/web-servers/apache-httpd/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/web-servers/apache-httpd/default.nix b/nixos/modules/services/web-servers/apache-httpd/default.nix index 7f50b8fd8d44..b2bb5055cd4c 100644 --- a/nixos/modules/services/web-servers/apache-httpd/default.nix +++ b/nixos/modules/services/web-servers/apache-httpd/default.nix @@ -22,7 +22,9 @@ let php = cfg.phpPackage.override { apacheHttpd = pkg; }; - phpMajorVersion = lib.versions.major (lib.getVersion php); + phpModuleName = let + majorVersion = lib.versions.major (lib.getVersion php); + in (if majorVersion == "8" then "php" else "php${majorVersion}"); mod_perl = pkgs.apacheHttpdPackages.mod_perl.override { apacheHttpd = pkg; }; @@ -63,7 +65,7 @@ let ++ optional enableSSL "ssl" ++ optional enableUserDir "userdir" ++ optional cfg.enableMellon { name = "auth_mellon"; path = "${pkgs.apacheHttpdPackages.mod_auth_mellon}/modules/mod_auth_mellon.so"; } - ++ optional cfg.enablePHP { name = "php${phpMajorVersion}"; path = "${php}/modules/libphp${phpMajorVersion}.so"; } + ++ optional cfg.enablePHP { name = phpModuleName; path = "${php}/modules/lib${phpModuleName}.so"; } ++ optional cfg.enablePerl { name = "perl"; path = "${mod_perl}/modules/mod_perl.so"; } ++ cfg.extraModules; From db439da3cdc5d3162dd275a54dcbb6d94f7230cd Mon Sep 17 00:00:00 2001 From: Elis Hirwing Date: Sun, 28 Feb 2021 21:16:08 +0100 Subject: [PATCH 6/6] nixos/tests/php: Select the right versions of the tests depending on version --- nixos/tests/all-tests.nix | 3 +++ pkgs/development/interpreters/php/generic.nix | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 773f91d86042..7d676e15fa97 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -307,6 +307,9 @@ in pgjwt = handleTest ./pgjwt.nix {}; pgmanage = handleTest ./pgmanage.nix {}; php = handleTest ./php {}; + php73 = handleTest ./php { php = pkgs.php73; }; + php74 = handleTest ./php { php = pkgs.php74; }; + php80 = handleTest ./php { php = pkgs.php80; }; pinnwand = handleTest ./pinnwand.nix {}; plasma5 = handleTest ./plasma5.nix {}; pleroma = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./pleroma.nix {}; diff --git a/pkgs/development/interpreters/php/generic.nix b/pkgs/development/interpreters/php/generic.nix index ec5f955370f3..659157e24c4a 100644 --- a/pkgs/development/interpreters/php/generic.nix +++ b/pkgs/development/interpreters/php/generic.nix @@ -112,7 +112,8 @@ let withExtensions = mkWithExtensions allArgs allExtensionFunctions; phpIni = "${phpWithExtensions}/lib/php.ini"; unwrapped = php; - tests = nixosTests.php; + # Select the right php tests for the php version + tests = nixosTests."php${lib.strings.replaceStrings [ "." ] [ "" ] (lib.versions.majorMinor php.version)}"; inherit (php-packages) extensions buildPecl; packages = php-packages.tools; meta = php.meta // {