From 597266d1a316eb8b2d01c44f03770d0a7df6fa9c Mon Sep 17 00:00:00 2001 From: Peter Simons Date: Wed, 11 Sep 2019 14:48:51 +0200 Subject: 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. (cherry picked from commit 86f8895abbfdb3ce118e0ca971f56c7f72871e29) --- nixpkgs/nixos/modules/services/mail/mailman.nix | 11 +++++++---- nixpkgs/pkgs/servers/mail/mailman/web.nix | 22 ++++++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/nixpkgs/nixos/modules/services/mail/mailman.nix b/nixpkgs/nixos/modules/services/mail/mailman.nix index 93f4d8899553..a3c007a55c94 100644 --- a/nixpkgs/nixos/modules/services/mail/mailman.nix +++ b/nixpkgs/nixos/modules/services/mail/mailman.nix @@ -62,6 +62,12 @@ let 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 { ###### interface @@ -88,10 +94,7 @@ in { webRoot = mkOption { type = types.path; - default = pkgs.python3Packages.mailman-web.override { serverEMail = cfg.siteOwner; - archiverKey = cfg.hyperkittyApiKey; - allowedHosts = cfg.webHosts; - }; + default = "${mailmanWeb}/${pkgs.python3.sitePackages}"; defaultText = "pkgs.python3Packages.mailman-web"; description = '' The web root for the Hyperkity + Postorius apps provided by Mailman. diff --git a/nixpkgs/pkgs/servers/mail/mailman/web.nix b/nixpkgs/pkgs/servers/mail/mailman/web.nix index da352ed3482d..b0ead765a605 100644 --- a/nixpkgs/pkgs/servers/mail/mailman/web.nix +++ b/nixpkgs/pkgs/servers/mail/mailman/web.nix @@ -1,4 +1,4 @@ -{ stdenv +{ stdenv, python, hyperkitty, postorius, buildPythonPackage , serverEMail ? "postmaster@example.org" , archiverKey ? "SecretArchiverAPIKey" , allowedHosts ? [] @@ -10,18 +10,28 @@ let 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"; + propagatedBuildInputs = [ hyperkitty postorius ]; + unpackPhase = ":"; + buildPhase = ":"; + setuptoolsCheckPhase = ":"; installPhase = '' - install -D -m 444 ${./urls.py} $out/urls.py - install -D -m 444 ${./wsgi.py} $out/wsgi.py - substitute ${./settings.py} $out/settings.py \ + 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 $out/settings.py + chmod 444 $d/settings.py ''; } -- cgit 1.4.1