From 22e8804308ff8e328f9f17210573a8a66c3b9a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=98=D0=B0=D0=BD=20=D0=93=D0=B5=D0=BE?= =?UTF-8?q?=D1=80=D0=B3=D0=B8=D0=B5=D0=B2=D1=81=D0=BA=D0=B8?= Date: Wed, 9 Sep 2020 12:51:40 +0200 Subject: [PATCH] uwsgi: the php plugin needs to link with session.so On NixOS the session.so php extension is a separate package (and not builtin in libphp.so). But since the uwsgi php plugin uses the session mechanisms, we need to link the plugin to that library too. With this change uwsgipluginpy is hacked to take an additional UWSGICONFIG_PHP_LDFLAGS environment variable and add it to its LDFLAGS, and then in the nix expression the UWSGICONFIG_PHP_LDFLAGS is set to point to php.extensions.session --- pkgs/servers/uwsgi/additional-php-ldflags.patch | 13 +++++++++++++ pkgs/servers/uwsgi/default.nix | 15 ++++++++++++++- ...> no-ext-session-php_session.h-on-NixOS.patch} | 0 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 pkgs/servers/uwsgi/additional-php-ldflags.patch rename pkgs/servers/uwsgi/{0001-no-ext-session-php_session.h-on-NixOS.patch => no-ext-session-php_session.h-on-NixOS.patch} (100%) diff --git a/pkgs/servers/uwsgi/additional-php-ldflags.patch b/pkgs/servers/uwsgi/additional-php-ldflags.patch new file mode 100644 index 000000000000..8549d5c2d03c --- /dev/null +++ b/pkgs/servers/uwsgi/additional-php-ldflags.patch @@ -0,0 +1,13 @@ +diff --git a/plugins/php/uwsgiplugin.py b/plugins/php/uwsgiplugin.py +index d930c44e..2fcbc22a 100644 +--- a/plugins/php/uwsgiplugin.py ++++ b/plugins/php/uwsgiplugin.py +@@ -17,6 +17,8 @@ php_version = os.popen(PHPPATH + ' --version').read().rstrip().split('.')[0] + CFLAGS = [os.popen(PHPPATH + ' --includes').read().rstrip(), '-Wno-sign-compare'] + LDFLAGS = os.popen(PHPPATH + ' --ldflags').read().rstrip().split() + ++LDFLAGS.append(os.environ.get('UWSGICONFIG_PHP_LDFLAGS', [])) ++ + if ld_run_path: + LDFLAGS.append('-L%s' % ld_run_path) + os.environ['LD_RUN_PATH'] = ld_run_path diff --git a/pkgs/servers/uwsgi/default.nix b/pkgs/servers/uwsgi/default.nix index bb2742ecba8e..cf69d76bd1a4 100644 --- a/pkgs/servers/uwsgi/default.nix +++ b/pkgs/servers/uwsgi/default.nix @@ -65,7 +65,10 @@ stdenv.mkDerivation rec { sha256 = "0256v72b7zr6ds4srpaawk1px3bp0djdwm239w3wrxpw7dzk1gjn"; }; - patches = [ ./0001-no-ext-session-php_session.h-on-NixOS.patch ]; + patches = [ + ./no-ext-session-php_session.h-on-NixOS.patch + ./additional-php-ldflags.patch + ]; nativeBuildInputs = [ python3 pkgconfig ]; @@ -89,6 +92,16 @@ stdenv.mkDerivation rec { substituteAll ${./nixos.ini} buildconf/nixos.ini ''; + # this is a hack to make the php plugin link with session.so (which on nixos is a separate package) + # the hack works in coordination with ./additional-php-ldflags.patch + UWSGICONFIG_PHP_LDFLAGS = lib.optionalString (builtins.any (x: x.name == "php") needed) + lib.concatStringsSep "," [ + "-Wl" + "-rpath=${php-embed.extensions.session}/lib/php/extensions/" + "--library-path=${php-embed.extensions.session}/lib/php/extensions/" + "-l:session.so" + ]; + buildPhase = '' mkdir -p $pluginDir python3 uwsgiconfig.py --build nixos diff --git a/pkgs/servers/uwsgi/0001-no-ext-session-php_session.h-on-NixOS.patch b/pkgs/servers/uwsgi/no-ext-session-php_session.h-on-NixOS.patch similarity index 100% rename from pkgs/servers/uwsgi/0001-no-ext-session-php_session.h-on-NixOS.patch rename to pkgs/servers/uwsgi/no-ext-session-php_session.h-on-NixOS.patch