2024-08-05 19:12:08 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
2019-08-27 14:55:24 +00:00
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.mailman;
|
|
|
|
|
2022-06-30 17:35:43 +00:00
|
|
|
inherit (pkgs.mailmanPackages.buildEnvs { withHyperkitty = cfg.hyperkitty.enable; withLDAP = cfg.ldap.enable; })
|
2022-05-19 23:36:48 +00:00
|
|
|
mailmanEnv webEnv;
|
2022-04-26 10:19:41 +00:00
|
|
|
|
|
|
|
withPostgresql = config.services.postgresql.enable;
|
2020-04-15 12:02:59 +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
|
|
|
# This deliberately doesn't use recursiveUpdate so users can
|
|
|
|
# override the defaults.
|
2020-05-22 14:52:10 +00:00
|
|
|
webSettings = {
|
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_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";
|
|
|
|
};
|
|
|
|
};
|
2020-05-26 08:36:01 +00:00
|
|
|
HAYSTACK_CONNECTIONS.default = {
|
|
|
|
ENGINE = "haystack.backends.whoosh_backend.WhooshEngine";
|
|
|
|
PATH = "/var/lib/mailman-web/fulltext-index";
|
|
|
|
};
|
2024-08-08 18:14:51 +00:00
|
|
|
} // lib.optionalAttrs cfg.enablePostfix {
|
|
|
|
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend";
|
|
|
|
EMAIL_HOST = "127.0.0.1";
|
|
|
|
EMAIL_PORT = 25;
|
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;
|
|
|
|
|
2020-05-22 14:52:10 +00:00
|
|
|
webSettingsJSON = pkgs.writeText "settings.json" (builtins.toJSON webSettings);
|
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?
|
2020-11-29 20:00:52 +00:00
|
|
|
postfixMtaConfig = pkgs.writeText "mailman-postfix.cfg" ''
|
2020-04-15 12:02:59 +00:00
|
|
|
[postfix]
|
|
|
|
postmap_command: ${pkgs.postfix}/bin/postmap
|
|
|
|
transport_file_type: hash
|
|
|
|
'';
|
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
mailmanCfg = lib.generators.toINI {} (lib.recursiveUpdate cfg.settings {
|
2023-05-18 13:45:29 +00:00
|
|
|
webservice.admin_pass = "#NIXOS_MAILMAN_REST_API_PASS_SECRET#";
|
|
|
|
});
|
2022-07-20 19:05:21 +00:00
|
|
|
|
|
|
|
mailmanCfgFile = pkgs.writeText "mailman-raw.cfg" mailmanCfg;
|
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 = [
|
2024-08-24 20:05:34 +00:00
|
|
|
(lib.mkRenamedOptionModule [ "services" "mailman" "hyperkittyBaseUrl" ]
|
2019-10-20 17:41:50 +00:00
|
|
|
[ "services" "mailman" "hyperkitty" "baseUrl" ])
|
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
(lib.mkRemovedOptionModule [ "services" "mailman" "hyperkittyApiKey" ] ''
|
2019-10-20 17:41:50 +00:00
|
|
|
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.
|
|
|
|
'')
|
2024-08-24 20:05:34 +00:00
|
|
|
(lib.mkRemovedOptionModule [ "services" "mailman" "package" ] ''
|
2022-04-26 10:19:41 +00:00
|
|
|
Didn't have an effect for several years.
|
|
|
|
'')
|
2019-10-20 17:41:50 +00:00
|
|
|
];
|
|
|
|
|
2019-08-27 14:55:24 +00:00
|
|
|
options = {
|
|
|
|
|
|
|
|
services.mailman = {
|
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
enable = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2019-08-27 14:55:24 +00:00
|
|
|
default = false;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = "Enable Mailman on this host. Requires an active MTA on the host (e.g. Postfix).";
|
2019-08-27 14:55:24 +00:00
|
|
|
};
|
|
|
|
|
2022-06-30 17:35:43 +00:00
|
|
|
ldap = {
|
2024-08-24 20:05:34 +00:00
|
|
|
enable = lib.mkEnableOption "LDAP auth";
|
|
|
|
serverUri = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2022-06-30 17:35:43 +00:00
|
|
|
example = "ldaps://ldap.host";
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-06-30 17:35:43 +00:00
|
|
|
LDAP host to connect against.
|
|
|
|
'';
|
|
|
|
};
|
2024-08-24 20:05:34 +00:00
|
|
|
bindDn = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2022-06-30 17:35:43 +00:00
|
|
|
example = "cn=root,dc=nixos,dc=org";
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-06-30 17:35:43 +00:00
|
|
|
Service account to bind against.
|
|
|
|
'';
|
|
|
|
};
|
2024-08-24 20:05:34 +00:00
|
|
|
bindPasswordFile = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2022-06-30 17:35:43 +00:00
|
|
|
example = "/run/secrets/ldap-bind";
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-12-18 00:31:14 +00:00
|
|
|
Path to the file containing the bind password of the service account
|
2022-08-03 20:46:41 +00:00
|
|
|
defined by [](#opt-services.mailman.ldap.bindDn).
|
2022-06-30 17:35:43 +00:00
|
|
|
'';
|
|
|
|
};
|
2024-08-24 20:05:34 +00:00
|
|
|
superUserGroup = lib.mkOption {
|
|
|
|
type = lib.types.nullOr lib.types.str;
|
2022-06-30 17:35:43 +00:00
|
|
|
default = null;
|
|
|
|
example = "cn=admin,ou=groups,dc=nixos,dc=org";
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-06-30 17:35:43 +00:00
|
|
|
Group where a user must be a member of to gain superuser rights.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
userSearch = {
|
2024-08-24 20:05:34 +00:00
|
|
|
query = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2022-06-30 17:35:43 +00:00
|
|
|
example = "(&(objectClass=inetOrgPerson)(|(uid=%(user)s)(mail=%(user)s)))";
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-06-30 17:35:43 +00:00
|
|
|
Query to find a user in the LDAP database.
|
|
|
|
'';
|
|
|
|
};
|
2024-08-24 20:05:34 +00:00
|
|
|
ou = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2022-06-30 17:35:43 +00:00
|
|
|
example = "ou=users,dc=nixos,dc=org";
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-06-30 17:35:43 +00:00
|
|
|
Organizational unit to look up a user.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
groupSearch = {
|
2024-08-24 20:05:34 +00:00
|
|
|
type = lib.mkOption {
|
|
|
|
type = lib.types.enum [
|
2022-06-30 17:35:43 +00:00
|
|
|
"posixGroup" "groupOfNames" "memberDNGroup" "nestedMemberDNGroup" "nestedGroupOfNames"
|
|
|
|
"groupOfUniqueNames" "nestedGroupOfUniqueNames" "activeDirectoryGroup" "nestedActiveDirectoryGroup"
|
|
|
|
"organizationalRoleGroup" "nestedOrganizationalRoleGroup"
|
|
|
|
];
|
|
|
|
default = "posixGroup";
|
2024-08-24 20:05:34 +00:00
|
|
|
apply = v: "${lib.toUpper (lib.substring 0 1 v)}${lib.substring 1 (lib.stringLength v) v}Type";
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-06-30 17:35:43 +00:00
|
|
|
Type of group to perform a group search against.
|
|
|
|
'';
|
|
|
|
};
|
2024-08-24 20:05:34 +00:00
|
|
|
query = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2022-06-30 17:35:43 +00:00
|
|
|
example = "(objectClass=groupOfNames)";
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-06-30 17:35:43 +00:00
|
|
|
Query to find a group associated to a user in the LDAP database.
|
|
|
|
'';
|
|
|
|
};
|
2024-08-24 20:05:34 +00:00
|
|
|
ou = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2022-06-30 17:35:43 +00:00
|
|
|
example = "ou=groups,dc=nixos,dc=org";
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-06-30 17:35:43 +00:00
|
|
|
Organizational unit to look up a group.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
attrMap = {
|
2024-08-24 20:05:34 +00:00
|
|
|
username = lib.mkOption {
|
2022-06-30 17:35:43 +00:00
|
|
|
default = "uid";
|
2024-08-24 20:05:34 +00:00
|
|
|
type = lib.types.str;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-07-28 21:19:15 +00:00
|
|
|
LDAP-attribute that corresponds to the `username`-attribute in mailman.
|
2022-06-30 17:35:43 +00:00
|
|
|
'';
|
|
|
|
};
|
2024-08-24 20:05:34 +00:00
|
|
|
firstName = lib.mkOption {
|
2022-06-30 17:35:43 +00:00
|
|
|
default = "givenName";
|
2024-08-24 20:05:34 +00:00
|
|
|
type = lib.types.str;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-07-28 21:19:15 +00:00
|
|
|
LDAP-attribute that corresponds to the `firstName`-attribute in mailman.
|
2022-06-30 17:35:43 +00:00
|
|
|
'';
|
|
|
|
};
|
2024-08-24 20:05:34 +00:00
|
|
|
lastName = lib.mkOption {
|
2022-06-30 17:35:43 +00:00
|
|
|
default = "sn";
|
2024-08-24 20:05:34 +00:00
|
|
|
type = lib.types.str;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-07-28 21:19:15 +00:00
|
|
|
LDAP-attribute that corresponds to the `lastName`-attribute in mailman.
|
2022-06-30 17:35:43 +00:00
|
|
|
'';
|
|
|
|
};
|
2024-08-24 20:05:34 +00:00
|
|
|
email = lib.mkOption {
|
2022-06-30 17:35:43 +00:00
|
|
|
default = "mail";
|
2024-08-24 20:05:34 +00:00
|
|
|
type = lib.types.str;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-07-28 21:19:15 +00:00
|
|
|
LDAP-attribute that corresponds to the `email`-attribute in mailman.
|
2022-06-30 17:35:43 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
enablePostfix = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2020-11-29 20:00:52 +00:00
|
|
|
default = true;
|
|
|
|
example = false;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2020-11-29 20:00:52 +00:00
|
|
|
Enable Postfix integration. Requires an active Postfix installation.
|
|
|
|
|
|
|
|
If you want to use another MTA, set this option to false and configure
|
|
|
|
settings in services.mailman.settings.mta.
|
|
|
|
|
|
|
|
Refer to the Mailman manual for more info.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
siteOwner = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2019-10-20 02:34:23 +00:00
|
|
|
example = "postmaster@example.org";
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2019-08-27 14:55:24 +00:00
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
webHosts = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.str;
|
2019-09-01 18:33:47 +00:00
|
|
|
default = [];
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2019-09-01 18:33:47 +00:00
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
webUser = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2020-04-15 12:02:59 +00:00
|
|
|
default = "mailman-web";
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2019-10-20 02:33:12 +00:00
|
|
|
User to run mailman-web as
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
webSettings = lib.mkOption {
|
|
|
|
type = lib.types.attrs;
|
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 = {};
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
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
|
|
|
Overrides for the default mailman-web Django settings.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
restApiPassFile = lib.mkOption {
|
2022-07-20 19:05:21 +00:00
|
|
|
default = null;
|
2024-08-24 20:05:34 +00:00
|
|
|
type = lib.types.nullOr lib.types.str;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-07-28 21:19:15 +00:00
|
|
|
Path to the file containing the value for `MAILMAN_REST_API_PASS`.
|
2022-07-20 19:05:21 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-15 12:02:59 +00:00
|
|
|
serve = {
|
2024-08-24 20:05:34 +00:00
|
|
|
enable = lib.mkEnableOption "automatic nginx and uwsgi setup for mailman-web";
|
2022-09-04 13:49:26 +00:00
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
virtualRoot = lib.mkOption {
|
2022-09-04 13:49:26 +00:00
|
|
|
default = "/";
|
|
|
|
example = lib.literalExpression "/lists";
|
2024-08-24 20:05:34 +00:00
|
|
|
type = lib.types.str;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-09-04 13:49:26 +00:00
|
|
|
Path to mount the mailman-web django application on.
|
|
|
|
'';
|
|
|
|
};
|
2020-04-15 12:02:59 +00:00
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
extraPythonPackages = lib.mkOption {
|
2024-04-13 12:54:15 +00:00
|
|
|
description = "Packages to add to the python environment used by mailman and mailman-web";
|
2024-08-24 20:05:34 +00:00
|
|
|
type = lib.types.listOf lib.types.package;
|
2020-04-15 12:02:59 +00:00
|
|
|
default = [];
|
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
settings = lib.mkOption {
|
2024-04-13 12:54:15 +00:00
|
|
|
description = "Settings for mailman.cfg";
|
2024-08-24 20:05:34 +00:00
|
|
|
type = lib.types.attrsOf (lib.types.attrsOf lib.types.str);
|
2020-05-22 14:52:10 +00:00
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
|
2019-10-20 17:41:50 +00:00
|
|
|
hyperkitty = {
|
2024-08-24 20:05:34 +00:00
|
|
|
enable = lib.mkEnableOption "the Hyperkitty archiver for Mailman";
|
2019-10-20 17:41:50 +00:00
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
baseUrl = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2021-04-15 19:04:48 +00:00
|
|
|
default = "http://localhost:18507/archives/";
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2019-10-20 17:41:50 +00:00
|
|
|
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
|
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2019-08-27 14:55:24 +00:00
|
|
|
|
2020-05-22 14:52:10 +00:00
|
|
|
services.mailman.settings = {
|
|
|
|
mailman.site_owner = lib.mkDefault cfg.siteOwner;
|
|
|
|
mailman.layout = "fhs";
|
|
|
|
|
|
|
|
"paths.fhs" = {
|
2022-04-26 10:19:41 +00:00
|
|
|
bin_dir = "${pkgs.mailmanPackages.mailman}/bin";
|
2020-05-22 14:52:10 +00:00
|
|
|
var_dir = "/var/lib/mailman";
|
|
|
|
queue_dir = "$var_dir/queue";
|
|
|
|
template_dir = "$var_dir/templates";
|
|
|
|
log_dir = "/var/log/mailman";
|
2023-10-06 08:34:54 +00:00
|
|
|
lock_dir = "/run/mailman/lock";
|
2020-05-22 14:52:10 +00:00
|
|
|
etc_dir = "/etc";
|
|
|
|
pid_file = "/run/mailman/master.pid";
|
|
|
|
};
|
|
|
|
|
2020-11-29 20:00:52 +00:00
|
|
|
mta.configuration = lib.mkDefault (if cfg.enablePostfix then "${postfixMtaConfig}" else throw "When Mailman Postfix integration is disabled, set `services.mailman.settings.mta.configuration` to the path of the config file required to integrate with your MTA.");
|
2020-05-22 14:52:10 +00:00
|
|
|
|
|
|
|
"archiver.hyperkitty" = lib.mkIf cfg.hyperkitty.enable {
|
|
|
|
class = "mailman_hyperkitty.Archiver";
|
|
|
|
enable = "yes";
|
|
|
|
configuration = "/var/lib/mailman/mailman-hyperkitty.cfg";
|
|
|
|
};
|
2020-05-22 12:12:43 +00:00
|
|
|
} // (let
|
|
|
|
loggerNames = ["root" "archiver" "bounce" "config" "database" "debug" "error" "fromusenet" "http" "locks" "mischief" "plugins" "runner" "smtp"];
|
|
|
|
loggerSectionNames = map (n: "logging.${n}") loggerNames;
|
|
|
|
in lib.genAttrs loggerSectionNames(name: { handler = "stderr"; })
|
|
|
|
);
|
2020-05-22 14:52:10 +00:00
|
|
|
|
2020-01-09 19:24:41 +00:00
|
|
|
assertions = let
|
|
|
|
inherit (config.services) postfix;
|
|
|
|
|
|
|
|
requirePostfixHash = optionPath: dataFile:
|
|
|
|
let
|
|
|
|
expected = "hash:/var/lib/mailman/data/${dataFile}";
|
2024-08-24 20:05:34 +00:00
|
|
|
value = lib.attrByPath optionPath [] postfix;
|
2020-01-09 19:24:41 +00:00
|
|
|
in
|
2024-08-24 20:05:34 +00:00
|
|
|
{ assertion = postfix.enable -> lib.isList value && lib.elem expected value;
|
2020-01-09 19:24:41 +00:00
|
|
|
message = ''
|
2024-08-24 20:05:34 +00:00
|
|
|
services.postfix.${lib.concatStringsSep "." optionPath} must contain
|
2020-01-09 19:24:41 +00:00
|
|
|
"${expected}".
|
|
|
|
See <https://mailman.readthedocs.io/en/latest/src/mailman/docs/mta.html>.
|
|
|
|
'';
|
|
|
|
};
|
2022-04-02 11:17:46 +00:00
|
|
|
in [
|
|
|
|
{ assertion = cfg.webHosts != [];
|
|
|
|
message = ''
|
|
|
|
services.mailman.serve.enable requires there to be at least one entry
|
|
|
|
in services.mailman.webHosts.
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
] ++ (lib.optionals cfg.enablePostfix [
|
2020-01-09 19:24:41 +00:00
|
|
|
{ assertion = postfix.enable;
|
2020-11-29 20:00:52 +00:00
|
|
|
message = ''
|
|
|
|
Mailman's default NixOS configuration requires Postfix to be enabled.
|
|
|
|
|
|
|
|
If you want to use another MTA, set services.mailman.enablePostfix
|
|
|
|
to false and configure settings in services.mailman.settings.mta.
|
|
|
|
|
|
|
|
Refer to <https://mailman.readthedocs.io/en/latest/src/mailman/docs/mta.html>
|
|
|
|
for more info.
|
|
|
|
'';
|
2019-08-27 14:55:24 +00:00
|
|
|
}
|
2024-08-05 19:12:08 +00:00
|
|
|
(requirePostfixHash [ "config" "relay_domains" ] "postfix_domains")
|
2020-01-09 19:24:41 +00:00
|
|
|
(requirePostfixHash [ "config" "transport_maps" ] "postfix_lmtp")
|
|
|
|
(requirePostfixHash [ "config" "local_recipient_maps" ] "postfix_lmtp")
|
2020-11-29 20:00:52 +00:00
|
|
|
]);
|
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."mailman3/settings.py".text = ''
|
|
|
|
import os
|
2023-05-18 13:45:29 +00:00
|
|
|
from configparser import ConfigParser
|
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
|
|
|
|
|
|
|
# Required by mailman_web.settings, but will be overridden when
|
|
|
|
# settings_local.json is loaded.
|
|
|
|
os.environ["SECRET_KEY"] = ""
|
|
|
|
|
2021-04-14 13:32:12 +00:00
|
|
|
from mailman_web.settings.base import *
|
|
|
|
from mailman_web.settings.mailman import *
|
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
|
|
|
|
|
|
|
import json
|
|
|
|
|
2020-05-22 14:52:10 +00:00
|
|
|
with open('${webSettingsJSON}') as f:
|
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
|
|
|
globals().update(json.load(f))
|
|
|
|
|
|
|
|
with open('/var/lib/mailman-web/settings_local.json') as f:
|
|
|
|
globals().update(json.load(f))
|
2022-06-30 17:35:43 +00:00
|
|
|
|
2023-05-18 13:45:29 +00:00
|
|
|
with open('/etc/mailman.cfg') as f:
|
|
|
|
config = ConfigParser()
|
|
|
|
config.read_file(f)
|
|
|
|
MAILMAN_REST_API_PASS = config['webservice']['admin_pass']
|
2022-07-20 19:05:21 +00:00
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
${lib.optionalString (cfg.ldap.enable) ''
|
2022-06-30 17:35:43 +00:00
|
|
|
import ldap
|
|
|
|
from django_auth_ldap.config import LDAPSearch, ${cfg.ldap.groupSearch.type}
|
|
|
|
AUTH_LDAP_SERVER_URI = "${cfg.ldap.serverUri}"
|
|
|
|
AUTH_LDAP_BIND_DN = "${cfg.ldap.bindDn}"
|
|
|
|
with open("${cfg.ldap.bindPasswordFile}") as f:
|
2022-07-04 18:26:26 +00:00
|
|
|
AUTH_LDAP_BIND_PASSWORD = f.read().rstrip('\n')
|
2022-06-30 17:35:43 +00:00
|
|
|
AUTH_LDAP_USER_SEARCH = LDAPSearch("${cfg.ldap.userSearch.ou}",
|
|
|
|
ldap.SCOPE_SUBTREE, "${cfg.ldap.userSearch.query}")
|
|
|
|
AUTH_LDAP_GROUP_TYPE = ${cfg.ldap.groupSearch.type}()
|
|
|
|
AUTH_LDAP_GROUP_SEARCH = LDAPSearch("${cfg.ldap.groupSearch.ou}",
|
|
|
|
ldap.SCOPE_SUBTREE, "${cfg.ldap.groupSearch.query}")
|
|
|
|
AUTH_LDAP_USER_ATTR_MAP = {
|
2024-08-24 20:05:34 +00:00
|
|
|
${lib.concatStrings (lib.flip lib.mapAttrsToList cfg.ldap.attrMap (key: value: ''
|
2022-06-30 17:35:43 +00:00
|
|
|
"${key}": "${value}",
|
|
|
|
''))}
|
|
|
|
}
|
2024-08-24 20:05:34 +00:00
|
|
|
${lib.optionalString (cfg.ldap.superUserGroup != null) ''
|
2022-06-30 17:35:43 +00:00
|
|
|
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
|
|
|
|
"is_superuser": "${cfg.ldap.superUserGroup}"
|
|
|
|
}
|
|
|
|
''}
|
|
|
|
AUTHENTICATION_BACKENDS = (
|
|
|
|
"django_auth_ldap.backend.LDAPBackend",
|
|
|
|
"django.contrib.auth.backends.ModelBackend"
|
|
|
|
)
|
|
|
|
''}
|
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
|
|
|
'';
|
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
services.nginx = lib.mkIf (cfg.serve.enable && cfg.webHosts != []) {
|
|
|
|
enable = lib.mkDefault true;
|
2021-10-17 15:15:12 +00:00
|
|
|
virtualHosts = lib.genAttrs cfg.webHosts (webHost: {
|
2020-04-15 12:02:59 +00:00
|
|
|
locations = {
|
2022-09-04 13:49:26 +00:00
|
|
|
${cfg.serve.virtualRoot}.extraConfig = "uwsgi_pass unix:/run/mailman-web.socket;";
|
2024-08-24 20:05:34 +00:00
|
|
|
"${lib.removeSuffix "/" cfg.serve.virtualRoot}/static/".alias = webSettings.STATIC_ROOT + "/";
|
2020-04-15 12:02:59 +00:00
|
|
|
};
|
2021-10-17 15:15:12 +00:00
|
|
|
});
|
2024-08-24 20:05:34 +00:00
|
|
|
proxyTimeout = lib.mkDefault "120s";
|
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
|
2022-05-19 23:36:48 +00:00
|
|
|
# want from {web,mailman}Env
|
2020-04-15 12:02:59 +00:00
|
|
|
pathsToLink = ["/bin"];
|
2022-05-19 23:36:48 +00:00
|
|
|
paths = [ mailmanEnv webEnv ];
|
|
|
|
# Only mailman-related stuff is installed, the rest is removed
|
|
|
|
# in `postBuild`.
|
|
|
|
ignoreCollisions = true;
|
2020-04-15 12:02:59 +00:00
|
|
|
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-11-29 20:00:52 +00:00
|
|
|
services.postfix = lib.mkIf cfg.enablePostfix {
|
2020-04-15 12:02:59 +00:00
|
|
|
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";
|
2022-04-05 10:10:51 +00:00
|
|
|
before = lib.optional cfg.enablePostfix "postfix.service";
|
2022-04-05 10:03:25 +00:00
|
|
|
after = [ "network.target" ]
|
2022-04-26 10:19:41 +00:00
|
|
|
++ lib.optional cfg.enablePostfix "postfix-setup.service"
|
|
|
|
++ lib.optional withPostgresql "postgresql.service";
|
2022-07-20 19:05:21 +00:00
|
|
|
restartTriggers = [ mailmanCfgFile ];
|
2024-08-24 20:05:34 +00:00
|
|
|
requires = lib.optional withPostgresql "postgresql.service";
|
2020-04-15 12:02:59 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
2022-05-19 23:36:48 +00:00
|
|
|
ExecStart = "${mailmanEnv}/bin/mailman start";
|
|
|
|
ExecStop = "${mailmanEnv}/bin/mailman stop";
|
2020-04-15 12:02:59 +00:00
|
|
|
User = "mailman";
|
|
|
|
Group = "mailman";
|
|
|
|
Type = "forking";
|
|
|
|
RuntimeDirectory = "mailman";
|
|
|
|
LogsDirectory = "mailman";
|
|
|
|
PIDFile = "/run/mailman/master.pid";
|
2023-10-18 06:39:57 +00:00
|
|
|
Restart = "on-failure";
|
|
|
|
TimeoutStartSec = 180;
|
|
|
|
TimeoutStopSec = 180;
|
2020-04-15 12:02:59 +00:00
|
|
|
};
|
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 ];
|
2024-08-24 20:05:34 +00:00
|
|
|
after = lib.optional withPostgresql "postgresql.service";
|
|
|
|
requires = lib.optional withPostgresql "postgresql.service";
|
2023-05-18 11:15:26 +00:00
|
|
|
serviceConfig.RemainAfterExit = true;
|
2021-03-10 23:38:53 +00:00
|
|
|
serviceConfig.Type = "oneshot";
|
2020-04-15 12:02:59 +00:00
|
|
|
script = ''
|
2022-07-20 19:05:21 +00:00
|
|
|
install -m0750 -o mailman -g mailman ${mailmanCfgFile} /etc/mailman.cfg
|
2023-05-18 13:45:29 +00:00
|
|
|
${if cfg.restApiPassFile == null then ''
|
|
|
|
sed -i "s/#NIXOS_MAILMAN_REST_API_PASS_SECRET#/$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 64)/g" \
|
|
|
|
/etc/mailman.cfg
|
|
|
|
'' else ''
|
2022-07-20 19:05:21 +00:00
|
|
|
${pkgs.replace-secret}/bin/replace-secret \
|
|
|
|
'#NIXOS_MAILMAN_REST_API_PASS_SECRET#' \
|
|
|
|
${cfg.restApiPassFile} \
|
|
|
|
/etc/mailman.cfg
|
|
|
|
''}
|
|
|
|
|
2020-04-15 12:02:59 +00:00
|
|
|
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)
|
|
|
|
|
2024-02-28 20:10:58 +00:00
|
|
|
install -m 0440 -o root -g mailman \
|
|
|
|
<(jq -n '.MAILMAN_ARCHIVER_KEY=$archiver_key | .SECRET_KEY=$secret_key' \
|
2020-04-15 12:02:59 +00:00
|
|
|
--arg archiver_key "$hyperkittyApiKey" \
|
2024-02-28 20:10:58 +00:00
|
|
|
--arg secret_key "$secretKey") \
|
|
|
|
"$mailmanWebCfg"
|
2020-04-15 12:02:59 +00:00
|
|
|
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";
|
2021-01-06 10:40:01 +00:00
|
|
|
before = [ "mailman-uwsgi.service" ];
|
2020-04-15 12:02:59 +00:00
|
|
|
requiredBy = [ "mailman-uwsgi.service" ];
|
|
|
|
restartTriggers = [ config.environment.etc."mailman3/settings.py".source ];
|
|
|
|
script = ''
|
2020-05-22 14:52:10 +00:00
|
|
|
[[ -e "${webSettings.STATIC_ROOT}" ]] && find "${webSettings.STATIC_ROOT}/" -mindepth 1 -delete
|
2022-05-19 23:36:48 +00:00
|
|
|
${webEnv}/bin/mailman-web migrate
|
|
|
|
${webEnv}/bin/mailman-web collectstatic
|
|
|
|
${webEnv}/bin/mailman-web compress
|
2020-04-15 12:02:59 +00:00
|
|
|
'';
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.webUser;
|
|
|
|
Group = "mailman";
|
|
|
|
Type = "oneshot";
|
|
|
|
WorkingDirectory = "/var/lib/mailman-web";
|
|
|
|
};
|
2019-09-01 18:33:47 +00:00
|
|
|
};
|
|
|
|
|
2024-08-24 20:05:34 +00:00
|
|
|
mailman-uwsgi = lib.mkIf cfg.serve.enable (let
|
2020-04-15 12:02:59 +00:00
|
|
|
uwsgiConfig.uwsgi = {
|
|
|
|
type = "normal";
|
|
|
|
plugins = ["python3"];
|
2022-05-19 23:36:48 +00:00
|
|
|
home = webEnv;
|
2021-04-15 19:04:48 +00:00
|
|
|
http = "127.0.0.1:18507";
|
2023-01-04 10:58:41 +00:00
|
|
|
}
|
|
|
|
// (if cfg.serve.virtualRoot == "/"
|
|
|
|
then { module = "mailman_web.wsgi:application"; }
|
|
|
|
else {
|
|
|
|
mount = "${cfg.serve.virtualRoot}=mailman_web.wsgi:application";
|
|
|
|
manage-script-name = true;
|
|
|
|
});
|
2020-04-15 12:02:59 +00:00
|
|
|
uwsgiConfigFile = pkgs.writeText "uwsgi-mailman.json" (builtins.toJSON uwsgiConfig);
|
|
|
|
in {
|
|
|
|
wantedBy = ["multi-user.target"];
|
2024-08-24 20:05:34 +00:00
|
|
|
after = lib.optional withPostgresql "postgresql.service";
|
2022-04-26 10:19:41 +00:00
|
|
|
requires = ["mailman-uwsgi.socket" "mailman-web-setup.service"]
|
2024-08-24 20:05:34 +00:00
|
|
|
++ lib.optional withPostgresql "postgresql.service";
|
2020-04-15 12:02:59 +00:00
|
|
|
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.
|
2023-10-11 20:04:37 +00:00
|
|
|
ExecStart = "${pkgs.coreutils}/bin/env -C $RUNTIME_DIRECTORY ${pkgs.uwsgi.override { plugins = ["python3"]; python3 = webEnv.python; }}/bin/uwsgi --json ${uwsgiConfigFile}";
|
2020-04-15 12:02:59 +00:00
|
|
|
User = cfg.webUser;
|
|
|
|
Group = "mailman";
|
|
|
|
RuntimeDirectory = "mailman-uwsgi";
|
2023-10-18 06:39:57 +00:00
|
|
|
Restart = "on-failure";
|
2020-04-15 12:02:59 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
mailman-daily = {
|
|
|
|
description = "Trigger daily Mailman events";
|
|
|
|
startAt = "daily";
|
2022-07-20 19:05:21 +00:00
|
|
|
restartTriggers = [ mailmanCfgFile ];
|
2020-04-15 12:02:59 +00:00
|
|
|
serviceConfig = {
|
2022-05-19 23:36:48 +00:00
|
|
|
ExecStart = "${mailmanEnv}/bin/mailman digests --send";
|
2020-04-15 12:02:59 +00:00
|
|
|
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 = {
|
2022-05-19 23:36:48 +00:00
|
|
|
ExecStart = "${webEnv}/bin/mailman-web qcluster";
|
2020-04-15 12:02:59 +00:00
|
|
|
User = cfg.webUser;
|
|
|
|
Group = "mailman";
|
|
|
|
WorkingDirectory = "/var/lib/mailman-web";
|
2023-10-18 06:39:57 +00:00
|
|
|
Restart = "on-failure";
|
2020-04-15 12:02:59 +00:00
|
|
|
};
|
2019-09-01 18:33:47 +00:00
|
|
|
};
|
2024-08-24 20:05:34 +00:00
|
|
|
} // lib.flip lib.mapAttrs' {
|
2020-04-15 12:02:59 +00:00
|
|
|
"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 = {
|
2022-05-19 23:36:48 +00:00
|
|
|
ExecStart = "${webEnv}/bin/mailman-web runjobs ${name}";
|
2020-04-15 12:02:59 +00:00
|
|
|
User = cfg.webUser;
|
|
|
|
Group = "mailman";
|
|
|
|
WorkingDirectory = "/var/lib/mailman-web";
|
|
|
|
};
|
|
|
|
}));
|
2019-08-27 14:55:24 +00:00
|
|
|
};
|
|
|
|
|
2020-04-27 16:03:44 +00:00
|
|
|
meta = {
|
2024-06-21 11:41:50 +00:00
|
|
|
maintainers = with lib.maintainers; [ qyliss ];
|
2023-01-24 23:33:40 +00:00
|
|
|
doc = ./mailman.md;
|
2020-04-27 16:03:44 +00:00
|
|
|
};
|
|
|
|
|
2019-08-27 14:55:24 +00:00
|
|
|
}
|