···
1
-
{ stdenv, nixosTests, lib, pkg-config, jansson, pcre, libxcrypt
# plugins: list of strings, eg. [ "python2" "python3" ]
, pam, withPAM ? stdenv.isLinux
···
, makeWrapper, fetchFromGitHub
13
-
let php-embed = php.override {
14
-
embedSupport = true;
15
-
apxs2Support = false;
21
+
php-embed = php.override {
22
+
embedSupport = true;
23
+
apxs2Support = false;
18
-
pythonPlugin = pkg : lib.nameValuePair "python${if pkg.isPy2 then "2" else "3"}" {
19
-
interpreter = pkg.pythonForBuild.interpreter;
20
-
path = "plugins/python";
21
-
inputs = [ pkg ncurses ];
23
-
install -Dm644 uwsgidecorators.py $out/${pkg.sitePackages}/uwsgidecorators.py
24
-
${pkg.pythonForBuild.executable} -m compileall $out/${pkg.sitePackages}/
25
-
${pkg.pythonForBuild.executable} -O -m compileall $out/${pkg.sitePackages}/
26
+
pythonPlugin = pkg : lib.nameValuePair "python${if pkg.isPy2 then "2" else "3"}" {
27
+
interpreter = pkg.pythonForBuild.interpreter;
28
+
path = "plugins/python";
29
+
inputs = [ pkg ncurses ];
31
+
install -Dm644 uwsgidecorators.py $out/${pkg.sitePackages}/uwsgidecorators.py
32
+
${pkg.pythonForBuild.executable} -m compileall $out/${pkg.sitePackages}/
33
+
${pkg.pythonForBuild.executable} -O -m compileall $out/${pkg.sitePackages}/
29
-
available = lib.listToAttrs [
30
-
(pythonPlugin python2)
31
-
(pythonPlugin python3)
32
-
(lib.nameValuePair "rack" {
33
-
path = "plugins/rack";
36
-
(lib.nameValuePair "cgi" {
37
-
# usage: https://uwsgi-docs.readthedocs.io/en/latest/CGI.html?highlight=cgi
38
-
path = "plugins/cgi";
41
-
(lib.nameValuePair "php" {
42
-
# usage: https://uwsgi-docs.readthedocs.io/en/latest/PHP.html#running-php-apps-with-nginx
43
-
path = "plugins/php";
46
-
php-embed.extensions.session
47
-
php-embed.extensions.session.dev
48
-
php-embed.unwrapped.dev
49
-
] ++ php-embed.unwrapped.buildInputs;
37
+
available = lib.listToAttrs [
38
+
(pythonPlugin python2)
39
+
(pythonPlugin python3)
40
+
(lib.nameValuePair "rack" {
41
+
path = "plugins/rack";
44
+
(lib.nameValuePair "cgi" {
45
+
# usage: https://uwsgi-docs.readthedocs.io/en/latest/CGI.html?highlight=cgi
46
+
path = "plugins/cgi";
49
+
(lib.nameValuePair "php" {
50
+
# usage: https://uwsgi-docs.readthedocs.io/en/latest/PHP.html#running-php-apps-with-nginx
51
+
path = "plugins/php";
54
+
php-embed.extensions.session
55
+
php-embed.extensions.session.dev
56
+
php-embed.unwrapped.dev
57
+
] ++ php-embed.unwrapped.buildInputs;
54
-
let all = lib.concatStringsSep ", " (lib.attrNames available);
55
-
in if lib.hasAttr name available
56
-
then lib.getAttr name available // { inherit name; }
57
-
else throw "Unknown UWSGI plugin ${name}, available : ${all}";
63
+
all = lib.concatStringsSep ", " (lib.attrNames available);
65
+
if lib.hasAttr name available
66
+
then lib.getAttr name available // { inherit name; }
67
+
else throw "Unknown UWSGI plugin ${name}, available : ${all}";
59
-
needed = builtins.map getPlugin plugins;
69
+
needed = builtins.map getPlugin plugins;
62
-
stdenv.mkDerivation rec {
72
+
stdenv.mkDerivation (finalAttrs: {
70
-
sha256 = "sha256-TUASYDyG+p1tlhmqi+ivaC7aW6UZBrPTFQUTYys5ICE=";
79
+
rev = finalAttrs.version;
80
+
hash = "sha256-pfy3EDXq3KVY2mC3BMAp/87IUiP4NhdTWZo+zVBJ+Pc=";
74
-
./no-ext-session-php_session.h-on-NixOS.patch
75
-
./additional-php-ldflags.patch
84
+
./no-ext-session-php_session.h-on-NixOS.patch
85
+
./additional-php-ldflags.patch
78
-
nativeBuildInputs = [ python3 pkg-config makeWrapper ];
88
+
nativeBuildInputs = [
buildInputs = [ jansson pcre libxcrypt ]
81
-
++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ expat zlib ]
82
-
++ lib.optional withPAM pam
83
-
++ lib.optional withSystemd systemd
84
-
++ lib.optional withCap libcap
85
-
++ lib.concatMap (x: x.inputs) needed
95
+
++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ expat zlib ]
96
+
++ lib.optional withPAM pam
97
+
++ lib.optional withSystemd systemd
98
+
++ lib.optional withCap libcap
99
+
++ lib.concatMap (x: x.inputs) needed;
basePlugins = lib.concatStringsSep ","
89
-
( lib.optional withPAM "pam"
90
-
++ lib.optional withSystemd "systemd_logger"
102
+
( lib.optional withPAM "pam"
103
+
++ lib.optional withSystemd "systemd_logger"
UWSGI_INCLUDES = lib.optionalString withCap "${libcap.dev}/include";
110
+
tests.uwsgi = nixosTests.uwsgi;
···
122
+
runHook preConfigure
export pluginDir=$out/lib/uwsgi
substituteAll ${./nixos.ini} buildconf/nixos.ini
127
+
runHook postConfigure
# 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
114
-
UWSGICONFIG_PHP_LDFLAGS = lib.optionalString (builtins.any (x: x.name == "php") needed)
115
-
(lib.concatStringsSep "," [
117
-
"-rpath=${php-embed.extensions.session}/lib/php/extensions/"
118
-
"--library-path=${php-embed.extensions.session}/lib/php/extensions/"
132
+
UWSGICONFIG_PHP_LDFLAGS = lib.optionalString
133
+
(builtins.any (x: x.name == "php") needed)
134
+
(lib.concatStringsSep "," [
136
+
"-rpath=${php-embed.extensions.session}/lib/php/extensions/"
137
+
"--library-path=${php-embed.extensions.session}/lib/php/extensions/"
python3 uwsgiconfig.py --build nixos
${lib.concatMapStringsSep ";" (x: "${x.preBuild or ""}\n ${x.interpreter or "python3"} uwsgiconfig.py --plugin ${x.path} nixos ${x.name}") needed}
install -Dm755 uwsgi $out/bin/uwsgi
${lib.concatMapStringsSep "\n" (x: x.install or "") needed}
157
+
runHook postInstall
postFixup = lib.optionalString (builtins.any (x: x.name == "php") needed)
···
wrapProgram $out/bin/uwsgi --set PHP_INI_SCAN_DIR ${php-embed}/lib
139
-
homepage = "https://uwsgi-docs.readthedocs.org/en/latest/";
description = "A fast, self-healing and developer/sysadmin-friendly application container server coded in pure C";
141
-
license = licenses.gpl2;
142
-
maintainers = with maintainers; [ abbradar schneefux globin ];
143
-
platforms = platforms.unix;
167
+
homepage = "https://uwsgi-docs.readthedocs.org/en/latest/";
168
+
license = lib.licenses.gpl2;
169
+
maintainers = with lib.maintainers; [ abbradar schneefux globin ];
170
+
platforms = lib.platforms.unix;
146
-
passthru.tests.uwsgi = nixosTests.uwsgi;