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

+27 -1
pkgs/servers/uwsgi/0001-no-ext-session-php_session.h-on-NixOS.patch pkgs/servers/uwsgi/no-ext-session-php_session.h-on-NixOS.patch
+13
pkgs/servers/uwsgi/additional-php-ldflags.patch
··· 1 + diff --git a/plugins/php/uwsgiplugin.py b/plugins/php/uwsgiplugin.py 2 + index d930c44e..2fcbc22a 100644 3 + --- a/plugins/php/uwsgiplugin.py 4 + +++ b/plugins/php/uwsgiplugin.py 5 + @@ -17,6 +17,8 @@ php_version = os.popen(PHPPATH + ' --version').read().rstrip().split('.')[0] 6 + CFLAGS = [os.popen(PHPPATH + ' --includes').read().rstrip(), '-Wno-sign-compare'] 7 + LDFLAGS = os.popen(PHPPATH + ' --ldflags').read().rstrip().split() 8 + 9 + +LDFLAGS.append(os.environ.get('UWSGICONFIG_PHP_LDFLAGS', [])) 10 + + 11 + if ld_run_path: 12 + LDFLAGS.append('-L%s' % ld_run_path) 13 + os.environ['LD_RUN_PATH'] = ld_run_path
+14 -1
pkgs/servers/uwsgi/default.nix
··· 65 65 sha256 = "0256v72b7zr6ds4srpaawk1px3bp0djdwm239w3wrxpw7dzk1gjn"; 66 66 }; 67 67 68 - patches = [ ./0001-no-ext-session-php_session.h-on-NixOS.patch ]; 68 + patches = [ 69 + ./no-ext-session-php_session.h-on-NixOS.patch 70 + ./additional-php-ldflags.patch 71 + ]; 69 72 70 73 nativeBuildInputs = [ python3 pkgconfig ]; 71 74 ··· 88 91 export pluginDir=$out/lib/uwsgi 89 92 substituteAll ${./nixos.ini} buildconf/nixos.ini 90 93 ''; 94 + 95 + # this is a hack to make the php plugin link with session.so (which on nixos is a separate package) 96 + # the hack works in coordination with ./additional-php-ldflags.patch 97 + UWSGICONFIG_PHP_LDFLAGS = lib.optionalString (builtins.any (x: x.name == "php") needed) 98 + (lib.concatStringsSep "," [ 99 + "-Wl" 100 + "-rpath=${php-embed.extensions.session}/lib/php/extensions/" 101 + "--library-path=${php-embed.extensions.session}/lib/php/extensions/" 102 + "-l:session.so" 103 + ]); 91 104 92 105 buildPhase = '' 93 106 mkdir -p $pluginDir