diff options
Diffstat (limited to 'customized/uwsgi.nix')
-rw-r--r-- | customized/uwsgi.nix | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/customized/uwsgi.nix b/customized/uwsgi.nix new file mode 100644 index 00000000..32217ed8 --- /dev/null +++ b/customized/uwsgi.nix | |||
@@ -0,0 +1,77 @@ | |||
1 | { stdenv, lib, fetchurl, pkgconfig, jansson | ||
2 | , plugins | ||
3 | , pam, withPAM ? stdenv.isLinux | ||
4 | , systemd, withSystemd ? stdenv.isLinux | ||
5 | , python2, python3, ncurses | ||
6 | , extraPlugins ? [] | ||
7 | }: | ||
8 | |||
9 | let pythonPlugin = pkg : { name = "python${if pkg ? isPy2 then "2" else "3"}"; | ||
10 | interpreter = pkg; | ||
11 | path = "plugins/python"; | ||
12 | deps = [ pkg ncurses ]; | ||
13 | install = '' | ||
14 | install -Dm644 uwsgidecorators.py $out/${pkg.sitePackages}/uwsgidecorators.py | ||
15 | ${pkg.executable} -m compileall $out/${pkg.sitePackages}/ | ||
16 | ${pkg.executable} -O -m compileall $out/${pkg.sitePackages}/ | ||
17 | ''; | ||
18 | }; | ||
19 | available = [ (pythonPlugin python2) | ||
20 | (pythonPlugin python3) | ||
21 | ] ++ extraPlugins; | ||
22 | needed = builtins.filter (x: lib.any (y: x.name == y) plugins) available; | ||
23 | in | ||
24 | |||
25 | assert builtins.filter (x: lib.all (y: y.name != x) available) plugins == []; | ||
26 | |||
27 | stdenv.mkDerivation rec { | ||
28 | name = "uwsgi-2.0.11.1"; | ||
29 | |||
30 | src = fetchurl { | ||
31 | url = "http://projects.unbit.it/downloads/${name}.tar.gz"; | ||
32 | sha256 = "11v2j9n204hlvi1p1wp4r3nn22fqyd1qlbqcfqddi77sih9x79vm"; | ||
33 | }; | ||
34 | |||
35 | nativeBuildInputs = [ python3 pkgconfig ]; | ||
36 | |||
37 | buildInputs = with stdenv.lib; | ||
38 | [ jansson ] | ||
39 | ++ optional withPAM pam | ||
40 | ++ optional withSystemd systemd | ||
41 | ++ lib.concatMap (x: x.deps) needed | ||
42 | ; | ||
43 | |||
44 | basePlugins = with stdenv.lib; | ||
45 | concatStringsSep "," | ||
46 | ( optional withPAM "pam" | ||
47 | ++ optional withSystemd "systemd_logger" | ||
48 | ); | ||
49 | |||
50 | passthru = { | ||
51 | inherit python2 python3; | ||
52 | }; | ||
53 | |||
54 | configurePhase = '' | ||
55 | export pluginDir=$out/lib/uwsgi | ||
56 | substituteAll ${./nixos.ini} buildconf/nixos.ini | ||
57 | ''; | ||
58 | |||
59 | buildPhase = '' | ||
60 | mkdir -p $pluginDir | ||
61 | python3 uwsgiconfig.py --build nixos | ||
62 | ${lib.concatMapStringsSep ";" (x: "${x.interpreter.interpreter} uwsgiconfig.py --plugin ${x.path} nixos ${x.name}") needed} | ||
63 | ''; | ||
64 | |||
65 | installPhase = '' | ||
66 | install -Dm755 uwsgi $out/bin/uwsgi | ||
67 | #cp *_plugin.so $pluginDir || true | ||
68 | ${lib.concatMapStringsSep "\n" (x: x.install) needed} | ||
69 | ''; | ||
70 | |||
71 | meta = with stdenv.lib; { | ||
72 | homepage = http://uwsgi-docs.readthedocs.org/en/latest/; | ||
73 | description = "A fast, self-healing and developer/sysadmin-friendly application container server coded in pure C"; | ||
74 | license = licenses.gpl2; | ||
75 | maintainers = with maintainers; [ abbradar ]; | ||
76 | }; | ||
77 | } | ||