diff options
-rw-r--r-- | customized/uwsgi-nixos.ini | 1 | ||||
-rw-r--r-- | customized/uwsgi.nix | 51 | ||||
-rw-r--r-- | ymir.nix | 9 |
3 files changed, 35 insertions, 26 deletions
diff --git a/customized/uwsgi-nixos.ini b/customized/uwsgi-nixos.ini index 454eb518..51bc6da3 100644 --- a/customized/uwsgi-nixos.ini +++ b/customized/uwsgi-nixos.ini | |||
@@ -2,4 +2,5 @@ | |||
2 | plugin_dir = @pluginDir@ | 2 | plugin_dir = @pluginDir@ |
3 | main_plugin = @basePlugins@ | 3 | main_plugin = @basePlugins@ |
4 | json = true | 4 | json = true |
5 | yaml = false | ||
5 | inherit = base | 6 | inherit = base |
diff --git a/customized/uwsgi.nix b/customized/uwsgi.nix index f3494264..87bd3238 100644 --- a/customized/uwsgi.nix +++ b/customized/uwsgi.nix | |||
@@ -1,31 +1,40 @@ | |||
1 | { stdenv, lib, fetchurl, pkgconfig, jansson | 1 | { stdenv, lib, fetchurl, pkgconfig, jansson |
2 | # plugins: list of strings, eg. [ "python2" "python3" ] | ||
2 | , plugins | 3 | , plugins |
3 | , pam, withPAM ? stdenv.isLinux | 4 | , pam, withPAM ? stdenv.isLinux |
4 | , systemd, withSystemd ? stdenv.isLinux | 5 | , systemd, withSystemd ? stdenv.isLinux |
5 | , python2, python3, ncurses | 6 | , python2, python3, ncurses |
6 | , extraPlugins ? [] | 7 | , extraPlugins ? {} |
7 | }: | 8 | }: |
8 | 9 | ||
9 | let pythonPlugin = pkg : { name = "python${if pkg ? isPy2 then "2" else "3"}"; | 10 | let pythonPlugin = pkg : lib.nameValuePair "python${if pkg ? isPy2 then "2" else "3"}" { |
10 | interpreter = pkg; | 11 | interpreter = pkg.interpreter; |
11 | path = "plugins/python"; | 12 | path = "plugins/python"; |
12 | deps = [ pkg ncurses ]; | 13 | inputs = [ pkg ncurses ]; |
13 | install = '' | 14 | install = '' |
14 | install -Dm644 uwsgidecorators.py $out/${pkg.sitePackages}/uwsgidecorators.py | 15 | install -Dm644 uwsgidecorators.py $out/${pkg.sitePackages}/uwsgidecorators.py |
15 | ${pkg.executable} -m compileall $out/${pkg.sitePackages}/ | 16 | ${pkg.executable} -m compileall $out/${pkg.sitePackages}/ |
16 | ${pkg.executable} -O -m compileall $out/${pkg.sitePackages}/ | 17 | ${pkg.executable} -O -m compileall $out/${pkg.sitePackages}/ |
17 | ''; | 18 | ''; |
18 | }; | 19 | }; |
19 | available = [ (pythonPlugin python2) | 20 | |
21 | available = (lib.listToAttrs [ | ||
22 | (pythonPlugin python2) | ||
20 | (pythonPlugin python3) | 23 | (pythonPlugin python3) |
21 | ] ++ extraPlugins; | 24 | ]) // extraPlugins; |
22 | needed = builtins.filter (x: lib.any (y: x.name == y) plugins) available; | ||
23 | in | ||
24 | 25 | ||
25 | assert builtins.filter (x: lib.all (y: y.name != x) available) plugins == []; | 26 | getPlugin = name: |
27 | let all = lib.concatStringsSep ", " (lib.attrNames available); | ||
28 | in if lib.hasAttr name available | ||
29 | then lib.getAttr name available // { inherit name; } | ||
30 | else throw "Unknown UWSGI plugin ${name}, available : ${all}"; | ||
31 | |||
32 | needed = builtins.map getPlugin plugins; | ||
33 | in | ||
26 | 34 | ||
27 | stdenv.mkDerivation rec { | 35 | stdenv.mkDerivation rec { |
28 | name = "uwsgi-2.0.13.1"; | 36 | name = "uwsgi-${version}"; |
37 | version = "2.0.13.1"; | ||
29 | 38 | ||
30 | src = fetchurl { | 39 | src = fetchurl { |
31 | url = "http://projects.unbit.it/downloads/${name}.tar.gz"; | 40 | url = "http://projects.unbit.it/downloads/${name}.tar.gz"; |
@@ -34,17 +43,15 @@ stdenv.mkDerivation rec { | |||
34 | 43 | ||
35 | nativeBuildInputs = [ python3 pkgconfig ]; | 44 | nativeBuildInputs = [ python3 pkgconfig ]; |
36 | 45 | ||
37 | buildInputs = with stdenv.lib; | 46 | buildInputs = [ jansson ] |
38 | [ jansson ] | 47 | ++ lib.optional withPAM pam |
39 | ++ optional withPAM pam | 48 | ++ lib.optional withSystemd systemd |
40 | ++ optional withSystemd systemd | 49 | ++ lib.concatMap (x: x.inputs) needed |
41 | ++ lib.concatMap (x: x.deps) needed | ||
42 | ; | 50 | ; |
43 | 51 | ||
44 | basePlugins = with stdenv.lib; | 52 | basePlugins = lib.concatStringsSep "," |
45 | concatStringsSep "," | 53 | ( lib.optional withPAM "pam" |
46 | ( optional withPAM "pam" | 54 | ++ lib.optional withSystemd "systemd_logger" |
47 | ++ optional withSystemd "systemd_logger" | ||
48 | ); | 55 | ); |
49 | 56 | ||
50 | passthru = { | 57 | passthru = { |
@@ -59,21 +66,21 @@ stdenv.mkDerivation rec { | |||
59 | buildPhase = '' | 66 | buildPhase = '' |
60 | mkdir -p $pluginDir | 67 | mkdir -p $pluginDir |
61 | python3 uwsgiconfig.py --build nixos | 68 | python3 uwsgiconfig.py --build nixos |
62 | ${lib.concatMapStringsSep ";" (x: "${x.interpreter.interpreter} uwsgiconfig.py --plugin ${x.path} nixos ${x.name}") needed} | 69 | ${lib.concatMapStringsSep ";" (x: "${x.interpreter} uwsgiconfig.py --plugin ${x.path} nixos ${x.name}") needed} |
63 | ''; | 70 | ''; |
64 | 71 | ||
65 | installPhase = '' | 72 | installPhase = '' |
66 | install -Dm755 uwsgi $out/bin/uwsgi | 73 | install -Dm755 uwsgi $out/bin/uwsgi |
67 | #cp *_plugin.so $pluginDir || true | ||
68 | ${lib.concatMapStringsSep "\n" (x: x.install) needed} | 74 | ${lib.concatMapStringsSep "\n" (x: x.install) needed} |
69 | ''; | 75 | ''; |
70 | 76 | ||
71 | NIX_CFLAGES_LINK = [ "-lsystemd" ]; | 77 | NIX_CFLAGS_LINK = [ "-lsystemd" ]; |
72 | 78 | ||
73 | meta = with stdenv.lib; { | 79 | meta = with stdenv.lib; { |
74 | homepage = http://uwsgi-docs.readthedocs.org/en/latest/; | 80 | homepage = http://uwsgi-docs.readthedocs.org/en/latest/; |
75 | description = "A fast, self-healing and developer/sysadmin-friendly application container server coded in pure C"; | 81 | description = "A fast, self-healing and developer/sysadmin-friendly application container server coded in pure C"; |
76 | license = licenses.gpl2; | 82 | license = licenses.gpl2; |
77 | maintainers = with maintainers; [ abbradar ]; | 83 | maintainers = with maintainers; [ abbradar ]; |
84 | platforms = platforms.linux; | ||
78 | }; | 85 | }; |
79 | } | 86 | } |
@@ -47,8 +47,9 @@ in rec { | |||
47 | extraLibs = [luaPam luaPosix luaSha2]; | 47 | extraLibs = [luaPam luaPosix luaSha2]; |
48 | }); | 48 | }); |
49 | uwsgi = pkgs.callPackage ./customized/uwsgi.nix { | 49 | uwsgi = pkgs.callPackage ./customized/uwsgi.nix { |
50 | extraPlugins = [ | 50 | extraPlugins = { |
51 | { name = "cgi"; | 51 | cgi = { |
52 | name = "cgi"; | ||
52 | interpreter = pkgs.python3; | 53 | interpreter = pkgs.python3; |
53 | path = "plugins/cgi"; | 54 | path = "plugins/cgi"; |
54 | deps = [ pkgs.python3 ]; | 55 | deps = [ pkgs.python3 ]; |
@@ -56,8 +57,8 @@ in rec { | |||
56 | ${pkgs.python3.executable} -m compileall $out/${pkgs.python3.sitePackages}/ | 57 | ${pkgs.python3.executable} -m compileall $out/${pkgs.python3.sitePackages}/ |
57 | ${pkgs.python3.executable} -O -m compileall $out/${pkgs.python3.sitePackages}/ | 58 | ${pkgs.python3.executable} -O -m compileall $out/${pkgs.python3.sitePackages}/ |
58 | ''; | 59 | ''; |
59 | } | 60 | }; |
60 | ]; | 61 | }; |
61 | plugins = []; | 62 | plugins = []; |
62 | }; | 63 | }; |
63 | cgit = pkgs.stdenv.lib.overrideDerivation pkgs.cgit (oldAttrs : { | 64 | cgit = pkgs.stdenv.lib.overrideDerivation pkgs.cgit (oldAttrs : { |