mailman: split python env for web and mailman

main
Maximilian Bosch 2 years ago
parent 72a14ea563
commit aea3ec632d
No known key found for this signature in database
GPG Key ID: 091DBF4D1FC46B8E
  1. 30
      nixos/modules/services/mail/mailman.nix
  2. 21
      pkgs/servers/mail/mailman/default.nix

@ -6,9 +6,8 @@ let
cfg = config.services.mailman; cfg = config.services.mailman;
pythonEnv = pkgs.mailmanPackages.buildEnv { inherit (pkgs.mailmanPackages.buildEnvs { withHyperkitty = cfg.hyperkitty.enable; })
withHyperkitty = cfg.hyperkitty.enable; mailmanEnv webEnv;
};
withPostgresql = config.services.postgresql.enable; withPostgresql = config.services.postgresql.enable;
@ -291,9 +290,12 @@ in {
name = "mailman-tools"; name = "mailman-tools";
# We don't want to pollute the system PATH with a python # We don't want to pollute the system PATH with a python
# interpreter etc. so let's pick only the stuff we actually # interpreter etc. so let's pick only the stuff we actually
# want from pythonEnv # want from {web,mailman}Env
pathsToLink = ["/bin"]; pathsToLink = ["/bin"];
paths = [pythonEnv]; paths = [ mailmanEnv webEnv ];
# Only mailman-related stuff is installed, the rest is removed
# in `postBuild`.
ignoreCollisions = true;
postBuild = '' postBuild = ''
find $out/bin/ -mindepth 1 -not -name "mailman*" -delete find $out/bin/ -mindepth 1 -not -name "mailman*" -delete
''; '';
@ -322,8 +324,8 @@ in {
requires = optional withPostgresql "postgresql.service"; requires = optional withPostgresql "postgresql.service";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
serviceConfig = { serviceConfig = {
ExecStart = "${pythonEnv}/bin/mailman start"; ExecStart = "${mailmanEnv}/bin/mailman start";
ExecStop = "${pythonEnv}/bin/mailman stop"; ExecStop = "${mailmanEnv}/bin/mailman stop";
User = "mailman"; User = "mailman";
Group = "mailman"; Group = "mailman";
Type = "forking"; Type = "forking";
@ -381,9 +383,9 @@ in {
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ]; restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
script = '' script = ''
[[ -e "${webSettings.STATIC_ROOT}" ]] && find "${webSettings.STATIC_ROOT}/" -mindepth 1 -delete [[ -e "${webSettings.STATIC_ROOT}" ]] && find "${webSettings.STATIC_ROOT}/" -mindepth 1 -delete
${pythonEnv}/bin/mailman-web migrate ${webEnv}/bin/mailman-web migrate
${pythonEnv}/bin/mailman-web collectstatic ${webEnv}/bin/mailman-web collectstatic
${pythonEnv}/bin/mailman-web compress ${webEnv}/bin/mailman-web compress
''; '';
serviceConfig = { serviceConfig = {
User = cfg.webUser; User = cfg.webUser;
@ -397,7 +399,7 @@ in {
uwsgiConfig.uwsgi = { uwsgiConfig.uwsgi = {
type = "normal"; type = "normal";
plugins = ["python3"]; plugins = ["python3"];
home = pythonEnv; home = webEnv;
module = "mailman_web.wsgi"; module = "mailman_web.wsgi";
http = "127.0.0.1:18507"; http = "127.0.0.1:18507";
}; };
@ -424,7 +426,7 @@ in {
startAt = "daily"; startAt = "daily";
restartTriggers = [ config.environment.etc."mailman.cfg".source ]; restartTriggers = [ config.environment.etc."mailman.cfg".source ];
serviceConfig = { serviceConfig = {
ExecStart = "${pythonEnv}/bin/mailman digests --send"; ExecStart = "${mailmanEnv}/bin/mailman digests --send";
User = "mailman"; User = "mailman";
Group = "mailman"; Group = "mailman";
}; };
@ -436,7 +438,7 @@ in {
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ]; restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
wantedBy = [ "mailman.service" "multi-user.target" ]; wantedBy = [ "mailman.service" "multi-user.target" ];
serviceConfig = { serviceConfig = {
ExecStart = "${pythonEnv}/bin/mailman-web qcluster"; ExecStart = "${webEnv}/bin/mailman-web qcluster";
User = cfg.webUser; User = cfg.webUser;
Group = "mailman"; Group = "mailman";
WorkingDirectory = "/var/lib/mailman-web"; WorkingDirectory = "/var/lib/mailman-web";
@ -455,7 +457,7 @@ in {
inherit startAt; inherit startAt;
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ]; restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
serviceConfig = { serviceConfig = {
ExecStart = "${pythonEnv}/bin/mailman-web runjobs ${name}"; ExecStart = "${webEnv}/bin/mailman-web runjobs ${name}";
User = cfg.webUser; User = cfg.webUser;
Group = "mailman"; Group = "mailman";
WorkingDirectory = "/var/lib/mailman-web"; WorkingDirectory = "/var/lib/mailman-web";

@ -16,15 +16,18 @@ let
web = callPackage ./web.nix { }; web = callPackage ./web.nix { };
buildEnv = { web ? self.web buildEnvs = { web ? self.web
, mailman ? self.mailman , mailman ? self.mailman
, mailman-hyperkitty ? self.mailman-hyperkitty , mailman-hyperkitty ? self.mailman-hyperkitty
, withHyperkitty ? false , withHyperkitty ? false
}: }:
self.python3.withPackages {
(ps: mailmanEnv = self.python3.withPackages
[ web mailman ps.psycopg2 ] (ps: [ mailman ps.psycopg2 ]
++ lib.optional withHyperkitty mailman-hyperkitty); ++ lib.optional withHyperkitty mailman-hyperkitty);
webEnv = self.python3.withPackages
(ps: [ web ps.psycopg2 ]);
};
}); });
in self in self

Loading…
Cancel
Save