summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-01-13 01:39:11 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2016-01-13 01:39:11 +0100
commit0da1c1ce3bfb134fb9d9eff6faf2b386f8d50d3d (patch)
treeca125bfb28deb7d4eda70f33ffe7bbe51c3ca63e
parent3f8e58df65f96650b3091e9040b44f603b4526e7 (diff)
downloadnixos-0da1c1ce3bfb134fb9d9eff6faf2b386f8d50d3d.tar
nixos-0da1c1ce3bfb134fb9d9eff6faf2b386f8d50d3d.tar.gz
nixos-0da1c1ce3bfb134fb9d9eff6faf2b386f8d50d3d.tar.bz2
nixos-0da1c1ce3bfb134fb9d9eff6faf2b386f8d50d3d.tar.xz
nixos-0da1c1ce3bfb134fb9d9eff6faf2b386f8d50d3d.zip
first stab at customized uwsgi
-rw-r--r--customized/uwsgi.nix77
-rw-r--r--ymir.nix13
2 files changed, 90 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
9let 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;
23in
24
25assert builtins.filter (x: lib.all (y: y.name != x) available) plugins == [];
26
27stdenv.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}
diff --git a/ymir.nix b/ymir.nix
index a11e95fb..99f127d6 100644
--- a/ymir.nix
+++ b/ymir.nix
@@ -43,6 +43,19 @@ in rec {
43 extraModules = [prosodyAuth]; 43 extraModules = [prosodyAuth];
44 extraLibs = [luaPam luaPosix luaSha2]; 44 extraLibs = [luaPam luaPosix luaSha2];
45 }); 45 });
46 uwsgi = pkgs.callPackage ./customized/uwsgi.nix {
47 extraPlugins = [
48 { name = "cgi";
49 interpreter = pkgs.python3;
50 path = "plugins/cgi";
51 deps = [ pkgs.python3 ];
52 install = ''
53 ${pkgs.python3.executable} -m compileall $out/${pkgs.python3.sitePackages}/
54 ${pkgs.python3.executable} -O -m compileall $out/${pkgs.pytho3.sitePackages}/
55 '';
56 }
57 ];
58 };
46 }; 59 };
47 60
48 environment.systemPackages = with pkgs; [ 61 environment.systemPackages = with pkgs; [