summary refs log tree commit diff
path: root/pkgs/servers/mail/mailman/web.nix
blob: ec16775b1d451920d88c3c18c972c43db5ca9f37 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{ stdenv, python, hyperkitty, postorius, buildPythonPackage, isPy3k
, serverEMail ? "postmaster@example.org"
, archiverKey ? "SecretArchiverAPIKey"
, allowedHosts ? []
}:

let

  allowedHostsString = stdenv.lib.concatMapStringsSep ", " (x: "\""+x+"\"") allowedHosts;

in

# We turn those Djando configuration files into a make-shift Python library so
# that Nix users can use this package as a part of their buildInputs to import
# the code. Also, this package implicitly provides an environment in which the
# Django app can be run.

buildPythonPackage {
  name = "mailman-web-0";
  disabled = !isPy3k;

  propagatedBuildInputs = [ hyperkitty postorius ];

  unpackPhase = ":";
  buildPhase = ":";
  setuptoolsCheckPhase = ":";

  installPhase = ''
    d=$out/${python.sitePackages}
    install -D -m 444 ${./urls.py} $d/urls.py
    install -D -m 444 ${./wsgi.py} $d/wsgi.py
    substitute ${./settings.py} $d/settings.py \
      --subst-var-by SERVER_EMAIL '${serverEMail}' \
      --subst-var-by ARCHIVER_KEY '${archiverKey}' \
      --subst-var-by ALLOWED_HOSTS '${allowedHostsString}'
    chmod 444 $d/settings.py
  '';
}