From f589f2b0fe95378eeebab3c352a9e88758c6cca2 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 14 Jun 2016 15:14:50 +0200 Subject: fixed uwsgi --- customized/uwsgi-nixos.ini | 1 + customized/uwsgi.nix | 51 ++++++++++++++++++++++++++-------------------- 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 @@ plugin_dir = @pluginDir@ main_plugin = @basePlugins@ json = true +yaml = false 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 @@ { stdenv, lib, fetchurl, pkgconfig, jansson +# plugins: list of strings, eg. [ "python2" "python3" ] , plugins , pam, withPAM ? stdenv.isLinux , systemd, withSystemd ? stdenv.isLinux , python2, python3, ncurses -, extraPlugins ? [] +, extraPlugins ? {} }: -let pythonPlugin = pkg : { name = "python${if pkg ? isPy2 then "2" else "3"}"; - interpreter = pkg; +let pythonPlugin = pkg : lib.nameValuePair "python${if pkg ? isPy2 then "2" else "3"}" { + interpreter = pkg.interpreter; path = "plugins/python"; - deps = [ pkg ncurses ]; + inputs = [ pkg ncurses ]; install = '' install -Dm644 uwsgidecorators.py $out/${pkg.sitePackages}/uwsgidecorators.py ${pkg.executable} -m compileall $out/${pkg.sitePackages}/ ${pkg.executable} -O -m compileall $out/${pkg.sitePackages}/ ''; }; - available = [ (pythonPlugin python2) + + available = (lib.listToAttrs [ + (pythonPlugin python2) (pythonPlugin python3) - ] ++ extraPlugins; - needed = builtins.filter (x: lib.any (y: x.name == y) plugins) available; -in + ]) // extraPlugins; -assert builtins.filter (x: lib.all (y: y.name != x) available) plugins == []; + getPlugin = name: + let all = lib.concatStringsSep ", " (lib.attrNames available); + in if lib.hasAttr name available + then lib.getAttr name available // { inherit name; } + else throw "Unknown UWSGI plugin ${name}, available : ${all}"; + + needed = builtins.map getPlugin plugins; +in stdenv.mkDerivation rec { - name = "uwsgi-2.0.13.1"; + name = "uwsgi-${version}"; + version = "2.0.13.1"; src = fetchurl { url = "http://projects.unbit.it/downloads/${name}.tar.gz"; @@ -34,17 +43,15 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ python3 pkgconfig ]; - buildInputs = with stdenv.lib; - [ jansson ] - ++ optional withPAM pam - ++ optional withSystemd systemd - ++ lib.concatMap (x: x.deps) needed + buildInputs = [ jansson ] + ++ lib.optional withPAM pam + ++ lib.optional withSystemd systemd + ++ lib.concatMap (x: x.inputs) needed ; - basePlugins = with stdenv.lib; - concatStringsSep "," - ( optional withPAM "pam" - ++ optional withSystemd "systemd_logger" + basePlugins = lib.concatStringsSep "," + ( lib.optional withPAM "pam" + ++ lib.optional withSystemd "systemd_logger" ); passthru = { @@ -59,21 +66,21 @@ stdenv.mkDerivation rec { buildPhase = '' mkdir -p $pluginDir python3 uwsgiconfig.py --build nixos - ${lib.concatMapStringsSep ";" (x: "${x.interpreter.interpreter} uwsgiconfig.py --plugin ${x.path} nixos ${x.name}") needed} + ${lib.concatMapStringsSep ";" (x: "${x.interpreter} uwsgiconfig.py --plugin ${x.path} nixos ${x.name}") needed} ''; installPhase = '' install -Dm755 uwsgi $out/bin/uwsgi - #cp *_plugin.so $pluginDir || true ${lib.concatMapStringsSep "\n" (x: x.install) needed} ''; - NIX_CFLAGES_LINK = [ "-lsystemd" ]; + NIX_CFLAGS_LINK = [ "-lsystemd" ]; meta = with stdenv.lib; { homepage = http://uwsgi-docs.readthedocs.org/en/latest/; description = "A fast, self-healing and developer/sysadmin-friendly application container server coded in pure C"; license = licenses.gpl2; maintainers = with maintainers; [ abbradar ]; + platforms = platforms.linux; }; } diff --git a/ymir.nix b/ymir.nix index 7b447e99..aade8d8e 100644 --- a/ymir.nix +++ b/ymir.nix @@ -47,8 +47,9 @@ in rec { extraLibs = [luaPam luaPosix luaSha2]; }); uwsgi = pkgs.callPackage ./customized/uwsgi.nix { - extraPlugins = [ - { name = "cgi"; + extraPlugins = { + cgi = { + name = "cgi"; interpreter = pkgs.python3; path = "plugins/cgi"; deps = [ pkgs.python3 ]; @@ -56,8 +57,8 @@ in rec { ${pkgs.python3.executable} -m compileall $out/${pkgs.python3.sitePackages}/ ${pkgs.python3.executable} -O -m compileall $out/${pkgs.python3.sitePackages}/ ''; - } - ]; + }; + }; plugins = []; }; cgit = pkgs.stdenv.lib.overrideDerivation pkgs.cgit (oldAttrs : { -- cgit v1.2.3