python-mailman-web: turn these Djando configuration files into a make-shift Python library

Suggested in https://github.com/NixOS/nixpkgs/pull/67951#issuecomment-530309702.
This commit is contained in:
Peter Simons 2019-09-11 14:48:51 +02:00
parent 72c7ba5aba
commit 86f8895abb
2 changed files with 23 additions and 10 deletions

View File

@ -62,6 +62,12 @@ let
installPhase = "install -D ${djangoPyEnv}/bin/django-admin $out/bin/mailman-django-admin"; installPhase = "install -D ${djangoPyEnv}/bin/django-admin $out/bin/mailman-django-admin";
}; };
mailmanWeb = pkgs.python3Packages.mailman-web.override {
serverEMail = cfg.siteOwner;
archiverKey = cfg.hyperkittyApiKey;
allowedHosts = cfg.webHosts;
};
in { in {
###### interface ###### interface
@ -88,10 +94,7 @@ in {
webRoot = mkOption { webRoot = mkOption {
type = types.path; type = types.path;
default = pkgs.python3Packages.mailman-web.override { serverEMail = cfg.siteOwner; default = "${mailmanWeb}/${pkgs.python3.sitePackages}";
archiverKey = cfg.hyperkittyApiKey;
allowedHosts = cfg.webHosts;
};
defaultText = "pkgs.python3Packages.mailman-web"; defaultText = "pkgs.python3Packages.mailman-web";
description = '' description = ''
The web root for the Hyperkity + Postorius apps provided by Mailman. The web root for the Hyperkity + Postorius apps provided by Mailman.

View File

@ -1,4 +1,4 @@
{ stdenv { stdenv, python, hyperkitty, postorius, buildPythonPackage
, serverEMail ? "postmaster@example.org" , serverEMail ? "postmaster@example.org"
, archiverKey ? "SecretArchiverAPIKey" , archiverKey ? "SecretArchiverAPIKey"
, allowedHosts ? [] , allowedHosts ? []
@ -10,18 +10,28 @@ let
in in
stdenv.mkDerivation { # 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"; name = "mailman-web-0";
propagatedBuildInputs = [ hyperkitty postorius ];
unpackPhase = ":"; unpackPhase = ":";
buildPhase = ":";
setuptoolsCheckPhase = ":";
installPhase = '' installPhase = ''
install -D -m 444 ${./urls.py} $out/urls.py d=$out/${python.sitePackages}
install -D -m 444 ${./wsgi.py} $out/wsgi.py install -D -m 444 ${./urls.py} $d/urls.py
substitute ${./settings.py} $out/settings.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 SERVER_EMAIL '${serverEMail}' \
--subst-var-by ARCHIVER_KEY '${archiverKey}' \ --subst-var-by ARCHIVER_KEY '${archiverKey}' \
--subst-var-by ALLOWED_HOSTS '${allowedHostsString}' --subst-var-by ALLOWED_HOSTS '${allowedHostsString}'
chmod 444 $out/settings.py chmod 444 $d/settings.py
''; '';
} }