<commit_before>{ stdenv, lib, fetchurl, pkgconfig, jansson
, plugins
, pam, withPAM ? stdenv.isLinux
, systemd, withSystemd ? stdenv.isLinux
, python2, python3, ncurses
}:

let pythonPlugin = pkg : { name = "python${if pkg ? isPy2 then "2" else "3"}";
                           interpreter = pkg;
                           path = "plugins/python";
                           deps = [ 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)
                  (pythonPlugin python3)
                ];
     needed = builtins.filter (x: lib.any (y: x.name == y) plugins) available;
in

assert builtins.filter (x: lib.all (y: y.name != x) available) plugins == [];

stdenv.mkDerivation rec {
  name = "uwsgi-2.0.10";

  src = fetchurl {
    url = "http://projects.unbit.it/downloads/${name}.tar.gz";
    sha256 = "12q2sn35vf1ils5043svq8da0czy54k63ziybvl33a9dqbb83cy0";
  };

  nativeBuildInputs = [ python3 pkgconfig ];

  buildInputs =  with stdenv.lib;
                 [ jansson ]
              ++ optional withPAM pam
              ++ optional withSystemd systemd
              ++ lib.concatMap (x: x.deps) needed
              ;

  basePlugins =  with stdenv.lib;
                 concatStringsSep ","
                 (  optional withPAM "pam"
                 ++ optional withSystemd "systemd_logger"
                 );

  passthru = {
    inherit python2 python3;
  };

  configurePhase = ''<commit_msg>uwsgi: update package<commit_after>{ stdenv, lib, fetchurl, pkgconfig, jansson
, plugins
, pam, withPAM ? stdenv.isLinux
, systemd, withSystemd ? stdenv.isLinux
, python2, python3, ncurses
}:

let pythonPlugin = pkg : { name = "python${if pkg ? isPy2 then "2" else "3"}";
                           interpreter = pkg;
                           path = "plugins/python";
                           deps = [ 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)
                  (pythonPlugin python3)
                ];
     needed = builtins.filter (x: lib.any (y: x.name == y) plugins) available;
in

assert builtins.filter (x: lib.all (y: y.name != x) available) plugins == [];

stdenv.mkDerivation rec {
  name = "uwsgi-2.0.11.1";

  src = fetchurl {
    url = "http://projects.unbit.it/downloads/${name}.tar.gz";
    sha256 = "11v2j9n204hlvi1p1wp4r3nn22fqyd1qlbqcfqddi77sih9x79vm";
  };

  nativeBuildInputs = [ python3 pkgconfig ];

  buildInputs =  with stdenv.lib;
                 [ jansson ]
              ++ optional withPAM pam
              ++ optional withSystemd systemd
              ++ lib.concatMap (x: x.deps) needed
              ;

  basePlugins =  with stdenv.lib;
                 concatStringsSep ","
                 (  optional withPAM "pam"
                 ++ optional withSystemd "systemd_logger"
                 );

  passthru = {
    inherit python2 python3;
  };

  configurePhase = ''
{'fraction_non_alphanumeric': 0.11457174638487208, 'fraction_numerical': 0.022803114571746386, 'mean_word_length': 1.6217201166180757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6790616', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1097, 'n_words': 230}