@@ -1,4 +1,4 @@
1−{ stdenv, lib, fetchurl, pkgconfig, jansson, pcre
1+{ stdenv, nixosTests, lib, fetchurl, pkgconfig, jansson, pcre
22# plugins: list of strings, eg. [ "python2" "python3" ]
33, plugins ? []
44, pam, withPAM ? stdenv.isLinux
@@ -38,8 +38,12 @@ let php-embed = php.override {
3838 (lib.nameValuePair "php" {
3939 # usage: https://uwsgi-docs.readthedocs.io/en/latest/PHP.html#running-php-apps-with-nginx
4040 path = "plugins/php";
41− inputs = [ php-embed ] ++ php-embed.buildInputs;
42− NIX_CFLAGS_LINK = [ "-L${libmysqlclient}/lib/mysql" ];
41+ inputs = [
42+ php-embed
43+ php-embed.extensions.session
44+ php-embed.extensions.session.dev
45+ php-embed.unwrapped.dev
46+ ] ++ php-embed.unwrapped.buildInputs;
4347 })
4448 ];
4549
@@ -61,6 +65,11 @@ stdenv.mkDerivation rec {
6165 sha256 = "0256v72b7zr6ds4srpaawk1px3bp0djdwm239w3wrxpw7dzk1gjn";
6266 };
6367
68+ patches = [
69+ ./no-ext-session-php_session.h-on-NixOS.patch
70+ ./additional-php-ldflags.patch
71+ ];
72+
6473 nativeBuildInputs = [ python3 pkgconfig ];
6574
6675 buildInputs = [ jansson pcre ]
@@ -83,6 +92,16 @@ stdenv.mkDerivation rec {
8392 substituteAll ${./nixos.ini} buildconf/nixos.ini
8493 '';
8594
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+ ]);
104+
86105 buildPhase = ''
87106 mkdir -p $pluginDir
88107 python3 uwsgiconfig.py --build nixos
@@ -94,8 +113,6 @@ stdenv.mkDerivation rec {
94113 ${lib.concatMapStringsSep "\n" (x: x.install or "") needed}
95114 '';
96115
97− NIX_CFLAGS_LINK = toString (lib.optional withSystemd "-lsystemd" ++ lib.concatMap (x: x.NIX_CFLAGS_LINK or []) needed);
98−
99116 meta = with stdenv.lib; {
100117 homepage = "https://uwsgi-docs.readthedocs.org/en/latest/";
101118 description = "A fast, self-healing and developer/sysadmin-friendly application container server coded in pure C";
@@ -103,4 +120,7 @@ stdenv.mkDerivation rec {
103120 maintainers = with maintainers; [ abbradar schneefux globin ];
104121 platforms = platforms.unix;
105122 };
123+
124+ passthru.tests.uwsgi = nixosTests.uwsgi;
125+
106126}