2019-08-27 14:55:24 +00:00
|
|
|
{ config, pkgs, lib, ... }: # mailman.nix
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.mailman;
|
|
|
|
|
2020-04-15 12:02:59 +00:00
|
|
|
pythonEnv = pkgs.python3.withPackages (ps:
|
|
|
|
[ps.mailman ps.mailman-web]
|
|
|
|
++ lib.optional cfg.hyperkitty.enable ps.mailman-hyperkitty
|
|
|
|
++ cfg.extraPythonPackages);
|
|
|
|
|
mailman-web: use upstream, improve NixOS module
Previously, some files were copied into the Nixpkgs tree, which meant
we wouldn't easily be able to update them, and was also just messy.
The reason it was done that way before was so that a few NixOS
options could be substituted in. Some problems with doing it this way
were that the _package_ changed depending on the values of the
settings, which is pretty strange, and also that it only allowed those
few settings to be set.
In the new model, mailman-web is a usable package without needing to
override, and I've implemented the NixOS options in a much more
flexible way. NixOS' mailman-web config file first reads the
mailman-web settings to use as defaults, but then it loads another
configuration file generated from the new services.mailman.webSettings
option, so _any_ mailman-web Django setting can be customised by the
user, rather than just the three that were supported before. I've
kept the old options, but there might not really be any good reason to
keep them.
2020-01-09 21:35:56 +00:00
|
|
|
# This deliberately doesn't use recursiveUpdate so users can
|
|
|
|
# override the defaults.
|
|
|
|
settings = {
|
|
|
|
DEFAULT_FROM_EMAIL = cfg.siteOwner;
|
|
|
|
SERVER_EMAIL = cfg.siteOwner;
|
|
|
|
ALLOWED_HOSTS = [ "localhost" "127.0.0.1" ] ++ cfg.webHosts;
|
|
|
|
COMPRESS_OFFLINE = true;
|
2020-04-15 12:02:59 +00:00
|
|
|
STATIC_ROOT = "/var/lib/mailman-web-static";
|
mailman-web: use upstream, improve NixOS module
Previously, some files were copied into the Nixpkgs tree, which meant
we wouldn't easily be able to update them, and was also just messy.
The reason it was done that way before was so that a few NixOS
options could be substituted in. Some problems with doing it this way
were that the _package_ changed depending on the values of the
settings, which is pretty strange, and also that it only allowed those
few settings to be set.
In the new model, mailman-web is a usable package without needing to
override, and I've implemented the NixOS options in a much more
flexible way. NixOS' mailman-web config file first reads the
mailman-web settings to use as defaults, but then it loads another
configuration file generated from the new services.mailman.webSettings
option, so _any_ mailman-web Django setting can be customised by the
user, rather than just the three that were supported before. I've
kept the old options, but there might not really be any good reason to
keep them.
2020-01-09 21:35:56 +00:00
|
|
|
MEDIA_ROOT = "/var/lib/mailman-web/media";
|
2020-04-15 12:02:59 +00:00
|
|
|
LOGGING = {
|
|
|
|
version = 1;
|
|
|
|
disable_existing_loggers = true;
|
|
|
|
handlers.console.class = "logging.StreamHandler";
|
|
|
|
loggers.django = {
|
|
|
|
handlers = [ "console" ];
|
|
|
|
level = "INFO";
|
|
|
|
};
|
|
|
|
};
|
mailman-web: use upstream, improve NixOS module
Previously, some files were copied into the Nixpkgs tree, which meant
we wouldn't easily be able to update them, and was also just messy.
The reason it was done that way before was so that a few NixOS
options could be substituted in. Some problems with doing it this way
were that the _package_ changed depending on the values of the
settings, which is pretty strange, and also that it only allowed those
few settings to be set.
In the new model, mailman-web is a usable package without needing to
override, and I've implemented the NixOS options in a much more
flexible way. NixOS' mailman-web config file first reads the
mailman-web settings to use as defaults, but then it loads another
configuration file generated from the new services.mailman.webSettings
option, so _any_ mailman-web Django setting can be customised by the
user, rather than just the three that were supported before. I've
kept the old options, but there might not really be any good reason to
keep them.
2020-01-09 21:35:56 +00:00
|
|
|
} // cfg.webSettings;
|
|
|
|
|
|
|
|
settingsJSON = pkgs.writeText "settings.json" (builtins.toJSON settings);
|
2019-09-11 13:22:37 +00:00
|
|
|
|
2020-04-15 12:02:59 +00:00
|
|
|
# TODO: Should this be RFC42-ised so that users can set additional options without modifying the module?
|
|
|
|
mtaConfig = pkgs.writeText "mailman-postfix.cfg" ''
|
|
|
|
[postfix]
|
|
|
|
postmap_command: ${pkgs.postfix}/bin/postmap
|
|
|
|
transport_file_type: hash
|
|
|
|
'';
|
|
|
|
|
2019-08-27 14:55:24 +00:00
|
|
|
mailmanCfg = ''
|
|
|
|
[mailman]
|
|
|
|
site_owner: ${cfg.siteOwner}
|
|
|
|
layout: fhs
|
|
|
|
|
|
|
|
[paths.fhs]
|
|
|
|
bin_dir: ${pkgs.python3Packages.mailman}/bin
|
|
|
|
var_dir: /var/lib/mailman
|
|
|
|
queue_dir: $var_dir/queue
|
2019-09-01 18:33:47 +00:00
|
|
|
template_dir: $var_dir/templates
|
2020-04-15 12:02:59 +00:00
|
|
|
log_dir: /var/log/mailman
|
2019-08-27 14:55:24 +00:00
|
|
|
lock_dir: $var_dir/lock
|
|
|
|
etc_dir: /etc
|
|
|
|
ext_dir: $etc_dir/mailman.d
|
|
|
|
pid_file: /run/mailman/master.pid
|
2020-04-15 12:02:59 +00:00
|
|
|
|
|
|
|
[mta]
|
|
|
|
configuration: ${mtaConfig}
|
2019-10-20 17:41:50 +00:00
|
|
|
'' + optionalString cfg.hyperkitty.enable ''
|
|
|
|
|
2019-09-01 18:33:47 +00:00
|
|
|
[archiver.hyperkitty]
|
|
|
|
class: mailman_hyperkitty.Archiver
|
|
|
|
enable: yes
|
2019-10-20 17:41:50 +00:00
|
|
|
configuration: /var/lib/mailman/mailman-hyperkitty.cfg
|
2019-08-27 14:55:24 +00:00
|
|
|
'';
|
|
|
|
|
2019-10-20 17:41:50 +00:00
|
|
|
mailmanHyperkittyCfg = pkgs.writeText "mailman-hyperkitty.cfg" ''
|
2019-09-01 18:33:47 +00:00
|
|
|
[general]
|
|
|
|
# This is your HyperKitty installation, preferably on the localhost. This
|
|
|
|
# address will be used by Mailman to forward incoming emails to HyperKitty
|
|
|
|
# for archiving. It does not need to be publicly available, in fact it's
|
|
|
|
# better if it is not.
|
2019-10-20 17:41:50 +00:00
|
|
|
base_url: ${cfg.hyperkitty.baseUrl}
|
2019-09-01 18:33:47 +00:00
|
|
|
|
|
|
|
# Shared API key, must be the identical to the value in HyperKitty's
|
|
|
|
# settings.
|
2019-10-20 17:41:50 +00:00
|
|
|
api_key: @API_KEY@
|
2019-09-01 18:33:47 +00:00
|
|
|
'';
|
|
|
|
|
2019-08-27 14:55:24 +00:00
|
|
|
in {
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
2019-10-20 17:41:50 +00:00
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "services" "mailman" "hyperkittyBaseUrl" ]
|
|
|
|
[ "services" "mailman" "hyperkitty" "baseUrl" ])
|
|
|
|
|
|
|
|
(mkRemovedOptionModule [ "services" "mailman" "hyperkittyApiKey" ] ''
|
|
|
|
The Hyperkitty API key is now generated on first run, and not
|
|
|
|
stored in the world-readable Nix store. To continue using
|
|
|
|
Hyperkitty, you must set services.mailman.hyperkitty.enable = true.
|
|
|
|
'')
|
|
|
|
];
|
|
|
|
|
2019-08-27 14:55:24 +00:00
|
|
|
options = {
|
|
|
|
|
|
|
|
services.mailman = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Enable Mailman on this host. Requires an active Postfix installation.";
|
|
|
|
};
|
|
|
|
|
2020-01-10 13:41:28 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.mailman;
|
|
|
|
defaultText = "pkgs.mailman";
|
2020-04-15 12:02:59 +00:00
|
|
|
example = literalExample "pkgs.mailman.override { archivers = []; }";
|
2020-01-10 13:41:28 +00:00
|
|
|
description = "Mailman package to use";
|
|
|
|
};
|
|
|
|
|
2019-08-27 14:55:24 +00:00
|
|
|
siteOwner = mkOption {
|
|
|
|
type = types.str;
|
2019-10-20 02:34:23 +00:00
|
|
|
example = "postmaster@example.org";
|
2019-08-27 14:55:24 +00:00
|
|
|
description = ''
|
|
|
|
Certain messages that must be delivered to a human, but which can't
|
|
|
|
be delivered to a list owner (e.g. a bounce from a list owner), will
|
|
|
|
be sent to this address. It should point to a human.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-09-01 18:33:47 +00:00
|
|
|
webHosts = mkOption {
|
2019-09-11 14:06:37 +00:00
|
|
|
type = types.listOf types.str;
|
2019-09-01 18:33:47 +00:00
|
|
|
default = [];
|
|
|
|
description = ''
|
|
|
|
The list of hostnames and/or IP addresses from which the Mailman Web
|
|
|
|
UI will accept requests. By default, "localhost" and "127.0.0.1" are
|
|
|
|
enabled. All additional names under which your web server accepts
|
|
|
|
requests for the UI must be listed here or incoming requests will be
|
|
|
|
rejected.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-10-20 02:33:12 +00:00
|
|
|
webUser = mkOption {
|
|
|
|
type = types.str;
|
2020-04-15 12:02:59 +00:00
|
|
|
default = "mailman-web";
|
2019-10-20 02:33:12 +00:00
|
|
|
description = ''
|
|
|
|
User to run mailman-web as
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
mailman-web: use upstream, improve NixOS module
Previously, some files were copied into the Nixpkgs tree, which meant
we wouldn't easily be able to update them, and was also just messy.
The reason it was done that way before was so that a few NixOS
options could be substituted in. Some problems with doing it this way
were that the _package_ changed depending on the values of the
settings, which is pretty strange, and also that it only allowed those
few settings to be set.
In the new model, mailman-web is a usable package without needing to
override, and I've implemented the NixOS options in a much more
flexible way. NixOS' mailman-web config file first reads the
mailman-web settings to use as defaults, but then it loads another
configuration file generated from the new services.mailman.webSettings
option, so _any_ mailman-web Django setting can be customised by the
user, rather than just the three that were supported before. I've
kept the old options, but there might not really be any good reason to
keep them.
2020-01-09 21:35:56 +00:00
|
|
|
webSettings = mkOption {
|
|
|
|
type = types.attrs;
|
|
|
|
default = {};
|
|
|
|
description = ''
|
|
|
|
Overrides for the default mailman-web Django settings.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-15 12:02:59 +00:00
|
|
|
serve = {
|
|
|
|
enable = mkEnableOption "Automatic nginx and uwsgi setup for mailman-web";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraPythonPackages = mkOption {
|
|
|
|
description = "Packages to add to the python environment used by mailman and mailman-web";
|
|
|
|
type = types.listOf types.package;
|
|
|
|
default = [];
|
|
|
|
};
|
|
|
|
|
2019-10-20 17:41:50 +00:00
|
|
|
hyperkitty = {
|
|
|
|
enable = mkEnableOption "the Hyperkitty archiver for Mailman";
|
|
|
|
|
|
|
|
baseUrl = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "http://localhost/hyperkitty/";
|
|
|
|
description = ''
|
|
|
|
Where can Mailman connect to Hyperkitty's internal API, preferably on
|
|
|
|
localhost?
|
|
|
|
'';
|
|
|
|
};
|
2019-09-01 18:33:47 +00:00
|
|
|
};
|
2019-08-27 14:55:24 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2020-01-09 19:24:41 +00:00
|
|
|
assertions = let
|
|
|
|
inherit (config.services) postfix;
|
|
|
|
|
|
|
|
requirePostfixHash = optionPath: dataFile:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
expected = "hash:/var/lib/mailman/data/${dataFile}";
|
|
|
|
value = attrByPath optionPath [] postfix;
|
|
|
|
in
|
|
|
|
{ assertion = postfix.enable -> isList value && elem expected value;
|
|
|
|
message = ''
|
|
|
|
services.postfix.${concatStringsSep "." optionPath} must contain
|
|
|
|
"${expected}".
|
|
|
|
See <https://mailman.readthedocs.io/en/latest/src/mailman/docs/mta.html>.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in [
|
|
|
|
{ assertion = postfix.enable;
|
2019-08-27 14:55:24 +00:00
|
|
|
message = "Mailman requires Postfix";
|
|
|
|
}
|
2020-01-09 19:24:41 +00:00
|
|
|
(requirePostfixHash [ "relayDomains" ] "postfix_domains")
|
|
|
|
(requirePostfixHash [ "config" "transport_maps" ] "postfix_lmtp")
|
|
|
|
(requirePostfixHash [ "config" "local_recipient_maps" ] "postfix_lmtp")
|
2019-08-27 14:55:24 +00:00
|
|
|
];
|
|
|
|
|
2020-04-15 12:02:59 +00:00
|
|
|
users.users.mailman = {
|
|
|
|
description = "GNU Mailman";
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "mailman";
|
|
|
|
};
|
|
|
|
users.users.mailman-web = lib.mkIf (cfg.webUser == "mailman-web") {
|
|
|
|
description = "GNU Mailman web interface";
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "mailman";
|
|
|
|
};
|
|
|
|
users.groups.mailman = {};
|
2019-08-27 14:55:24 +00:00
|
|
|
|
mailman-web: use upstream, improve NixOS module
Previously, some files were copied into the Nixpkgs tree, which meant
we wouldn't easily be able to update them, and was also just messy.
The reason it was done that way before was so that a few NixOS
options could be substituted in. Some problems with doing it this way
were that the _package_ changed depending on the values of the
settings, which is pretty strange, and also that it only allowed those
few settings to be set.
In the new model, mailman-web is a usable package without needing to
override, and I've implemented the NixOS options in a much more
flexible way. NixOS' mailman-web config file first reads the
mailman-web settings to use as defaults, but then it loads another
configuration file generated from the new services.mailman.webSettings
option, so _any_ mailman-web Django setting can be customised by the
user, rather than just the three that were supported before. I've
kept the old options, but there might not really be any good reason to
keep them.
2020-01-09 21:35:56 +00:00
|
|
|
environment.etc."mailman.cfg".text = mailmanCfg;
|
|
|
|
|
|
|
|
environment.etc."mailman3/settings.py".text = ''
|
|
|
|
import os
|
|
|
|
|
|
|
|
# Required by mailman_web.settings, but will be overridden when
|
|
|
|
# settings_local.json is loaded.
|
|
|
|
os.environ["SECRET_KEY"] = ""
|
|
|
|
|
|
|
|
from mailman_web.settings import *
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
with open('${settingsJSON}') as f:
|
|
|
|
globals().update(json.load(f))
|
|
|
|
|
|
|
|
with open('/var/lib/mailman-web/settings_local.json') as f:
|
|
|
|
globals().update(json.load(f))
|
|
|
|
'';
|
|
|
|
|
2020-04-15 12:02:59 +00:00
|
|
|
services.nginx = mkIf cfg.serve.enable {
|
|
|
|
enable = mkDefault true;
|
|
|
|
virtualHosts."${lib.head cfg.webHosts}" = {
|
|
|
|
serverAliases = cfg.webHosts;
|
|
|
|
locations = {
|
|
|
|
"/".extraConfig = "uwsgi_pass unix:/run/mailman-web.socket;";
|
|
|
|
"/static/".alias = settings.STATIC_ROOT + "/";
|
|
|
|
};
|
2019-10-20 17:41:50 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-04-15 12:02:59 +00:00
|
|
|
environment.systemPackages = [ (pkgs.buildEnv {
|
|
|
|
name = "mailman-tools";
|
|
|
|
# We don't want to pollute the system PATH with a python
|
|
|
|
# interpreter etc. so let's pick only the stuff we actually
|
|
|
|
# want from pythonEnv
|
|
|
|
pathsToLink = ["/bin"];
|
|
|
|
paths = [pythonEnv];
|
|
|
|
postBuild = ''
|
|
|
|
find $out/bin/ -mindepth 1 -not -name "mailman*" -delete
|
2019-09-01 18:33:47 +00:00
|
|
|
'';
|
2020-04-15 12:02:59 +00:00
|
|
|
}) ];
|
2019-09-01 18:33:47 +00:00
|
|
|
|
2020-04-15 12:02:59 +00:00
|
|
|
services.postfix = {
|
|
|
|
recipientDelimiter = "+"; # bake recipient addresses in mail envelopes via VERP
|
|
|
|
config = {
|
|
|
|
owner_request_special = "no"; # Mailman handles -owner addresses on its own
|
2019-09-01 18:33:47 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-04-15 12:02:59 +00:00
|
|
|
systemd.sockets.mailman-uwsgi = lib.mkIf cfg.serve.enable {
|
|
|
|
wantedBy = ["sockets.target"];
|
|
|
|
before = ["nginx.service"];
|
|
|
|
socketConfig.ListenStream = "/run/mailman-web.socket";
|
2019-09-01 18:33:47 +00:00
|
|
|
};
|
2020-04-15 12:02:59 +00:00
|
|
|
systemd.services = {
|
|
|
|
mailman = {
|
|
|
|
description = "GNU Mailman Master Process";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
restartTriggers = [ config.environment.etc."mailman.cfg".source ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pythonEnv}/bin/mailman start";
|
|
|
|
ExecStop = "${pythonEnv}/bin/mailman stop";
|
|
|
|
User = "mailman";
|
|
|
|
Group = "mailman";
|
|
|
|
Type = "forking";
|
|
|
|
RuntimeDirectory = "mailman";
|
|
|
|
LogsDirectory = "mailman";
|
|
|
|
PIDFile = "/run/mailman/master.pid";
|
|
|
|
};
|
2019-09-01 18:33:47 +00:00
|
|
|
};
|
|
|
|
|
2020-04-15 12:02:59 +00:00
|
|
|
mailman-settings = {
|
|
|
|
description = "Generate settings files (including secrets) for Mailman";
|
|
|
|
before = [ "mailman.service" "mailman-web-setup.service" "mailman-uwsgi.service" "hyperkitty.service" ];
|
|
|
|
requiredBy = [ "mailman.service" "mailman-web-setup.service" "mailman-uwsgi.service" "hyperkitty.service" ];
|
|
|
|
path = with pkgs; [ jq ];
|
|
|
|
script = ''
|
|
|
|
mailmanDir=/var/lib/mailman
|
|
|
|
mailmanWebDir=/var/lib/mailman-web
|
|
|
|
|
|
|
|
mailmanCfg=$mailmanDir/mailman-hyperkitty.cfg
|
|
|
|
mailmanWebCfg=$mailmanWebDir/settings_local.json
|
|
|
|
|
|
|
|
install -m 0775 -o mailman -g mailman -d /var/lib/mailman-web-static
|
|
|
|
install -m 0770 -o mailman -g mailman -d $mailmanDir
|
|
|
|
install -m 0770 -o ${cfg.webUser} -g mailman -d $mailmanWebDir
|
|
|
|
|
|
|
|
if [ ! -e $mailmanWebCfg ]; then
|
|
|
|
hyperkittyApiKey=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 64)
|
|
|
|
secretKey=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 64)
|
|
|
|
|
|
|
|
mailmanWebCfgTmp=$(mktemp)
|
|
|
|
jq -n '.MAILMAN_ARCHIVER_KEY=$archiver_key | .SECRET_KEY=$secret_key' \
|
|
|
|
--arg archiver_key "$hyperkittyApiKey" \
|
|
|
|
--arg secret_key "$secretKey" \
|
|
|
|
>"$mailmanWebCfgTmp"
|
|
|
|
chown root:mailman "$mailmanWebCfgTmp"
|
|
|
|
chmod 440 "$mailmanWebCfgTmp"
|
|
|
|
mv -n "$mailmanWebCfgTmp" "$mailmanWebCfg"
|
|
|
|
fi
|
|
|
|
|
|
|
|
hyperkittyApiKey="$(jq -r .MAILMAN_ARCHIVER_KEY "$mailmanWebCfg")"
|
|
|
|
mailmanCfgTmp=$(mktemp)
|
|
|
|
sed "s/@API_KEY@/$hyperkittyApiKey/g" ${mailmanHyperkittyCfg} >"$mailmanCfgTmp"
|
|
|
|
chown mailman:mailman "$mailmanCfgTmp"
|
|
|
|
mv "$mailmanCfgTmp" "$mailmanCfg"
|
|
|
|
'';
|
2019-09-01 18:33:47 +00:00
|
|
|
};
|
|
|
|
|
2020-04-15 12:02:59 +00:00
|
|
|
mailman-web-setup = {
|
|
|
|
description = "Prepare mailman-web files and database";
|
|
|
|
before = [ "uwsgi.service" "mailman-uwsgi.service" ];
|
|
|
|
requiredBy = [ "mailman-uwsgi.service" ];
|
|
|
|
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
|
|
|
|
script = ''
|
|
|
|
find "${settings.STATIC_ROOT}/" -mindepth 1 -delete
|
|
|
|
${pythonEnv}/bin/mailman-web migrate
|
|
|
|
${pythonEnv}/bin/mailman-web collectstatic
|
|
|
|
${pythonEnv}/bin/mailman-web compress
|
|
|
|
'';
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.webUser;
|
|
|
|
Group = "mailman";
|
|
|
|
Type = "oneshot";
|
|
|
|
WorkingDirectory = "/var/lib/mailman-web";
|
|
|
|
};
|
2019-09-01 18:33:47 +00:00
|
|
|
};
|
|
|
|
|
2020-04-15 12:02:59 +00:00
|
|
|
mailman-uwsgi = mkIf cfg.serve.enable (let
|
|
|
|
uwsgiConfig.uwsgi = {
|
|
|
|
type = "normal";
|
|
|
|
plugins = ["python3"];
|
|
|
|
home = pythonEnv;
|
|
|
|
module = "mailman_web.wsgi";
|
|
|
|
};
|
|
|
|
uwsgiConfigFile = pkgs.writeText "uwsgi-mailman.json" (builtins.toJSON uwsgiConfig);
|
|
|
|
in {
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
requires = ["mailman-uwsgi.socket" "mailman-web-setup.service"];
|
|
|
|
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
|
|
|
|
serviceConfig = {
|
|
|
|
# Since the mailman-web settings.py obstinately creates a logs
|
|
|
|
# dir in the cwd, change to the (writable) runtime directory before
|
|
|
|
# starting uwsgi.
|
|
|
|
ExecStart = "${pkgs.coreutils}/bin/env -C $RUNTIME_DIRECTORY ${pkgs.uwsgi.override { plugins = ["python3"]; }}/bin/uwsgi --json ${uwsgiConfigFile}";
|
|
|
|
User = cfg.webUser;
|
|
|
|
Group = "mailman";
|
|
|
|
RuntimeDirectory = "mailman-uwsgi";
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
mailman-daily = {
|
|
|
|
description = "Trigger daily Mailman events";
|
|
|
|
startAt = "daily";
|
|
|
|
restartTriggers = [ config.environment.etc."mailman.cfg".source ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pythonEnv}/bin/mailman digests --send";
|
|
|
|
User = "mailman";
|
|
|
|
Group = "mailman";
|
|
|
|
};
|
2019-09-01 18:33:47 +00:00
|
|
|
};
|
|
|
|
|
2020-04-15 12:02:59 +00:00
|
|
|
hyperkitty = lib.mkIf cfg.hyperkitty.enable {
|
|
|
|
description = "GNU Hyperkitty QCluster Process";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
|
|
|
|
wantedBy = [ "mailman.service" "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pythonEnv}/bin/mailman-web qcluster";
|
|
|
|
User = cfg.webUser;
|
|
|
|
Group = "mailman";
|
|
|
|
WorkingDirectory = "/var/lib/mailman-web";
|
|
|
|
};
|
2019-09-01 18:33:47 +00:00
|
|
|
};
|
2020-04-15 12:02:59 +00:00
|
|
|
} // flip lib.mapAttrs' {
|
|
|
|
"minutely" = "minutely";
|
|
|
|
"quarter_hourly" = "*:00/15";
|
|
|
|
"hourly" = "hourly";
|
|
|
|
"daily" = "daily";
|
|
|
|
"weekly" = "weekly";
|
|
|
|
"yearly" = "yearly";
|
|
|
|
} (name: startAt:
|
|
|
|
lib.nameValuePair "hyperkitty-${name}" (lib.mkIf cfg.hyperkitty.enable {
|
|
|
|
description = "Trigger ${name} Hyperkitty events";
|
|
|
|
inherit startAt;
|
|
|
|
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pythonEnv}/bin/mailman-web runjobs minutely";
|
|
|
|
User = cfg.webUser;
|
|
|
|
Group = "mailman";
|
|
|
|
WorkingDirectory = "/var/lib/mailman-web";
|
|
|
|
};
|
|
|
|
}));
|
2019-08-27 14:55:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|