2019-08-27 15:55:24 +01:00
|
|
|
{ config, pkgs, lib, ... }: # mailman.nix
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.mailman;
|
|
|
|
|
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;
|
|
|
|
STATIC_ROOT = "/var/lib/mailman-web/static";
|
|
|
|
MEDIA_ROOT = "/var/lib/mailman-web/media";
|
|
|
|
} // cfg.webSettings;
|
|
|
|
|
|
|
|
settingsJSON = pkgs.writeText "settings.json" (builtins.toJSON settings);
|
2019-09-11 14:22:37 +01:00
|
|
|
|
2019-08-27 15:55:24 +01: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 19:33:47 +01:00
|
|
|
template_dir: $var_dir/templates
|
2019-08-27 15:55:24 +01:00
|
|
|
log_dir: $var_dir/log
|
|
|
|
lock_dir: $var_dir/lock
|
|
|
|
etc_dir: /etc
|
|
|
|
ext_dir: $etc_dir/mailman.d
|
|
|
|
pid_file: /run/mailman/master.pid
|
2019-10-20 18:41:50 +01:00
|
|
|
'' + optionalString cfg.hyperkitty.enable ''
|
|
|
|
|
2019-09-01 19:33:47 +01:00
|
|
|
[archiver.hyperkitty]
|
|
|
|
class: mailman_hyperkitty.Archiver
|
|
|
|
enable: yes
|
2019-10-20 18:41:50 +01:00
|
|
|
configuration: /var/lib/mailman/mailman-hyperkitty.cfg
|
2019-08-27 15:55:24 +01:00
|
|
|
'';
|
|
|
|
|
2019-10-20 18:41:50 +01:00
|
|
|
mailmanHyperkittyCfg = pkgs.writeText "mailman-hyperkitty.cfg" ''
|
2019-09-01 19:33:47 +01: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 18:41:50 +01:00
|
|
|
base_url: ${cfg.hyperkitty.baseUrl}
|
2019-09-01 19:33:47 +01:00
|
|
|
|
|
|
|
# Shared API key, must be the identical to the value in HyperKitty's
|
|
|
|
# settings.
|
2019-10-20 18:41:50 +01:00
|
|
|
api_key: @API_KEY@
|
2019-09-01 19:33:47 +01:00
|
|
|
'';
|
|
|
|
|
2019-08-27 15:55:24 +01:00
|
|
|
in {
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
2019-10-20 18:41:50 +01: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 15:55:24 +01: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";
|
|
|
|
example = "pkgs.mailman.override { archivers = []; }";
|
|
|
|
description = "Mailman package to use";
|
|
|
|
};
|
|
|
|
|
2019-08-27 15:55:24 +01:00
|
|
|
siteOwner = mkOption {
|
|
|
|
type = types.str;
|
2019-10-20 03:34:23 +01:00
|
|
|
example = "postmaster@example.org";
|
2019-08-27 15:55:24 +01: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 19:33:47 +01:00
|
|
|
webRoot = mkOption {
|
|
|
|
type = types.path;
|
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
|
|
|
default = "${pkgs.mailman-web}/${pkgs.python3.sitePackages}";
|
|
|
|
defaultText = "\${pkgs.mailman-web}/\${pkgs.python3.sitePackages}";
|
2019-09-01 19:33:47 +01:00
|
|
|
description = ''
|
|
|
|
The web root for the Hyperkity + Postorius apps provided by Mailman.
|
|
|
|
This variable can be set, of course, but it mainly exists so that site
|
2020-01-09 17:07:15 +00:00
|
|
|
admins can refer to it in their own hand-written web server
|
|
|
|
configuration files.
|
2019-09-01 19:33:47 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
webHosts = mkOption {
|
2019-09-11 15:06:37 +01:00
|
|
|
type = types.listOf types.str;
|
2019-09-01 19:33:47 +01: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 03:33:12 +01:00
|
|
|
webUser = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = config.services.httpd.user;
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-10-20 18:41:50 +01: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 19:33:47 +01:00
|
|
|
};
|
2019-08-27 15:55:24 +01: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 15:55:24 +01: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 15:55:24 +01:00
|
|
|
];
|
|
|
|
|
2019-08-30 16:55:59 +01:00
|
|
|
users.users.mailman = { description = "GNU Mailman"; isSystemUser = true; };
|
2019-08-27 15:55:24 +01: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))
|
|
|
|
'';
|
|
|
|
|
|
|
|
environment.systemPackages = [ cfg.package ] ++ (with pkgs; [ mailman-web ]);
|
2019-08-27 15:55:24 +01:00
|
|
|
|
2019-08-30 17:42:28 +01:00
|
|
|
services.postfix = {
|
2019-09-01 19:33:47 +01:00
|
|
|
recipientDelimiter = "+"; # bake recipient addresses in mail envelopes via VERP
|
2019-08-30 17:42:28 +01:00
|
|
|
config = {
|
2019-09-01 19:33:47 +01:00
|
|
|
owner_request_special = "no"; # Mailman handles -owner addresses on its own
|
2019-08-30 17:42:28 +01:00
|
|
|
};
|
2019-08-27 15:55:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.mailman = {
|
|
|
|
description = "GNU Mailman Master Process";
|
|
|
|
after = [ "network.target" ];
|
2020-01-10 13:36:39 +00:00
|
|
|
restartTriggers = [ config.environment.etc."mailman.cfg".source ];
|
2019-08-27 15:55:24 +01:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
2020-01-10 13:41:28 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/mailman start";
|
|
|
|
ExecStop = "${cfg.package}/bin/mailman stop";
|
2019-08-27 15:55:24 +01:00
|
|
|
User = "mailman";
|
|
|
|
Type = "forking";
|
|
|
|
RuntimeDirectory = "mailman";
|
|
|
|
PIDFile = "/run/mailman/master.pid";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
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
|
|
|
systemd.services.mailman-settings = {
|
|
|
|
description = "Generate settings files (including secrets) for Mailman";
|
2019-10-20 18:41:50 +01:00
|
|
|
before = [ "mailman.service" "mailman-web.service" "hyperkitty.service" "httpd.service" "uwsgi.service" ];
|
|
|
|
requiredBy = [ "mailman.service" "mailman-web.service" "hyperkitty.service" "httpd.service" "uwsgi.service" ];
|
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
|
|
|
path = with pkgs; [ jq ];
|
2019-10-20 18:41:50 +01:00
|
|
|
script = ''
|
|
|
|
mailmanDir=/var/lib/mailman
|
|
|
|
mailmanWebDir=/var/lib/mailman-web
|
|
|
|
|
|
|
|
mailmanCfg=$mailmanDir/mailman-hyperkitty.cfg
|
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
|
|
|
mailmanWebCfg=$mailmanWebDir/settings_local.json
|
2019-10-20 18:41:50 +01:00
|
|
|
|
|
|
|
install -m 0700 -o mailman -g nogroup -d $mailmanDir
|
|
|
|
install -m 0700 -o ${cfg.webUser} -g nogroup -d $mailmanWebDir
|
|
|
|
|
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
|
|
|
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)
|
2019-10-20 18:41:50 +01: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
|
|
|
mailmanWebCfgTmp=$(mktemp)
|
|
|
|
jq -n '.MAILMAN_ARCHIVER_KEY=$archiver_key | .SECRET_KEY=$secret_key' \
|
|
|
|
--arg archiver_key "$hyperkittyApiKey" \
|
|
|
|
--arg secret_key "$secretKey" \
|
|
|
|
>"$mailmanWebCfgTmp"
|
|
|
|
chown ${cfg.webUser} "$mailmanWebCfgTmp"
|
|
|
|
mv -n "$mailmanWebCfgTmp" $mailmanWebCfg
|
|
|
|
fi
|
2019-10-20 18:41:50 +01: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
|
|
|
hyperkittyApiKey="$(jq -r .MAILMAN_ARCHIVER_KEY $mailmanWebCfg)"
|
2019-10-20 18:41:50 +01:00
|
|
|
mailmanCfgTmp=$(mktemp)
|
|
|
|
sed "s/@API_KEY@/$hyperkittyApiKey/g" ${mailmanHyperkittyCfg} >"$mailmanCfgTmp"
|
|
|
|
chown mailman "$mailmanCfgTmp"
|
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
|
|
|
mv "$mailmanCfgTmp" $mailmanCfg
|
2019-10-20 18:41:50 +01:00
|
|
|
'';
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
2020-03-01 21:00:01 +00:00
|
|
|
# RemainAfterExit makes restartIfChanged work for this service, so
|
|
|
|
# downstream services will get updated automatically when things like
|
|
|
|
# services.mailman.hyperkitty.baseUrl change. Otherwise users have to
|
|
|
|
# restart things manually, which is confusing.
|
|
|
|
RemainAfterExit = "yes";
|
2019-10-20 18:41:50 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-09-01 19:33:47 +01:00
|
|
|
systemd.services.mailman-web = {
|
|
|
|
description = "Init Postorius DB";
|
2020-01-09 17:07:15 +00:00
|
|
|
before = [ "httpd.service" "uwsgi.service" ];
|
|
|
|
requiredBy = [ "httpd.service" "uwsgi.service" ];
|
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
|
|
|
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
|
2019-09-01 19:33:47 +01:00
|
|
|
script = ''
|
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
|
|
|
${pkgs.mailman-web}/bin/mailman-web migrate
|
2019-09-01 19:33:47 +01:00
|
|
|
rm -rf 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
|
|
|
${pkgs.mailman-web}/bin/mailman-web collectstatic
|
|
|
|
${pkgs.mailman-web}/bin/mailman-web compress
|
2019-09-01 19:33:47 +01:00
|
|
|
'';
|
|
|
|
serviceConfig = {
|
2019-10-20 03:33:12 +01:00
|
|
|
User = cfg.webUser;
|
2019-09-01 19:33:47 +01:00
|
|
|
Type = "oneshot";
|
2020-03-01 21:00:01 +00:00
|
|
|
# Similar to mailman-settings.service, this makes restartTriggers work
|
|
|
|
# properly for this service.
|
|
|
|
RemainAfterExit = "yes";
|
2019-09-01 19:33:47 +01:00
|
|
|
WorkingDirectory = "/var/lib/mailman-web";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.mailman-daily = {
|
|
|
|
description = "Trigger daily Mailman events";
|
|
|
|
startAt = "daily";
|
2020-01-10 13:36:39 +00:00
|
|
|
restartTriggers = [ config.environment.etc."mailman.cfg".source ];
|
2019-09-01 19:33:47 +01:00
|
|
|
serviceConfig = {
|
2020-01-10 13:41:28 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/mailman digests --send";
|
2019-09-01 19:33:47 +01:00
|
|
|
User = "mailman";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.hyperkitty = {
|
2019-10-20 18:41:50 +01:00
|
|
|
inherit (cfg.hyperkitty) enable;
|
2019-09-01 19:33:47 +01:00
|
|
|
description = "GNU Hyperkitty QCluster Process";
|
|
|
|
after = [ "network.target" ];
|
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
|
|
|
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
|
2019-09-01 19:33:47 +01:00
|
|
|
wantedBy = [ "mailman.service" "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
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
|
|
|
ExecStart = "${pkgs.mailman-web}/bin/mailman-web qcluster";
|
2019-10-20 03:33:12 +01:00
|
|
|
User = cfg.webUser;
|
2019-09-01 19:33:47 +01:00
|
|
|
WorkingDirectory = "/var/lib/mailman-web";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.hyperkitty-minutely = {
|
2019-10-20 18:41:50 +01:00
|
|
|
inherit (cfg.hyperkitty) enable;
|
2019-09-01 19:33:47 +01:00
|
|
|
description = "Trigger minutely Hyperkitty events";
|
|
|
|
startAt = "minutely";
|
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
|
|
|
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
|
2019-09-01 19:33:47 +01:00
|
|
|
serviceConfig = {
|
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
|
|
|
ExecStart = "${pkgs.mailman-web}/bin/mailman-web runjobs minutely";
|
2019-10-20 03:33:12 +01:00
|
|
|
User = cfg.webUser;
|
2019-09-01 19:33:47 +01:00
|
|
|
WorkingDirectory = "/var/lib/mailman-web";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.hyperkitty-quarter-hourly = {
|
2019-10-20 18:41:50 +01:00
|
|
|
inherit (cfg.hyperkitty) enable;
|
2019-09-01 19:33:47 +01:00
|
|
|
description = "Trigger quarter-hourly Hyperkitty events";
|
|
|
|
startAt = "*:00/15";
|
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
|
|
|
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
|
2019-09-01 19:33:47 +01:00
|
|
|
serviceConfig = {
|
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
|
|
|
ExecStart = "${pkgs.mailman-web}/bin/mailman-web runjobs quarter_hourly";
|
2019-10-20 03:33:12 +01:00
|
|
|
User = cfg.webUser;
|
2019-09-01 19:33:47 +01:00
|
|
|
WorkingDirectory = "/var/lib/mailman-web";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.hyperkitty-hourly = {
|
2019-10-20 18:41:50 +01:00
|
|
|
inherit (cfg.hyperkitty) enable;
|
2019-09-01 19:33:47 +01:00
|
|
|
description = "Trigger hourly Hyperkitty events";
|
|
|
|
startAt = "hourly";
|
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
|
|
|
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
|
2019-09-01 19:33:47 +01:00
|
|
|
serviceConfig = {
|
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
|
|
|
ExecStart = "${pkgs.mailman-web}/bin/mailman-web runjobs hourly";
|
2019-10-20 03:33:12 +01:00
|
|
|
User = cfg.webUser;
|
2019-09-01 19:33:47 +01:00
|
|
|
WorkingDirectory = "/var/lib/mailman-web";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.hyperkitty-daily = {
|
2019-10-20 18:41:50 +01:00
|
|
|
inherit (cfg.hyperkitty) enable;
|
2019-09-01 19:33:47 +01:00
|
|
|
description = "Trigger daily Hyperkitty events";
|
|
|
|
startAt = "daily";
|
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
|
|
|
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
|
2019-09-01 19:33:47 +01:00
|
|
|
serviceConfig = {
|
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
|
|
|
ExecStart = "${pkgs.mailman-web}/bin/mailman-web runjobs daily";
|
2019-10-20 03:33:12 +01:00
|
|
|
User = cfg.webUser;
|
2019-09-01 19:33:47 +01:00
|
|
|
WorkingDirectory = "/var/lib/mailman-web";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.hyperkitty-weekly = {
|
2019-10-20 18:41:50 +01:00
|
|
|
inherit (cfg.hyperkitty) enable;
|
2019-09-01 19:33:47 +01:00
|
|
|
description = "Trigger weekly Hyperkitty events";
|
|
|
|
startAt = "weekly";
|
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
|
|
|
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
|
2019-09-01 19:33:47 +01:00
|
|
|
serviceConfig = {
|
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
|
|
|
ExecStart = "${pkgs.mailman-web}/bin/mailman-web runjobs weekly";
|
2019-10-20 03:33:12 +01:00
|
|
|
User = cfg.webUser;
|
2019-09-01 19:33:47 +01:00
|
|
|
WorkingDirectory = "/var/lib/mailman-web";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.hyperkitty-yearly = {
|
2019-10-20 18:41:50 +01:00
|
|
|
inherit (cfg.hyperkitty) enable;
|
2019-09-01 19:33:47 +01:00
|
|
|
description = "Trigger yearly Hyperkitty events";
|
|
|
|
startAt = "yearly";
|
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
|
|
|
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
|
2019-09-01 19:33:47 +01:00
|
|
|
serviceConfig = {
|
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
|
|
|
ExecStart = "${pkgs.mailman-web}/bin/mailman-web runjobs yearly";
|
2019-10-20 03:33:12 +01:00
|
|
|
User = cfg.webUser;
|
2019-09-01 19:33:47 +01:00
|
|
|
WorkingDirectory = "/var/lib/mailman-web";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-08-27 15:55:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|