Start migrating to NixOS mailman3 service.

This commit is contained in:
Kevin Baensch 2019-12-26 11:05:18 +01:00
parent 3791e05369
commit 47b88cfd35
Signed by: derped
GPG key ID: C0F1D326C7626543
4 changed files with 80 additions and 0 deletions

View file

@ -7,6 +7,7 @@
./hydra.nix
./mailserver/default.nix
./mailserver.nix
./mailman3.nix
./mariaDB.nix
./nextcloud.nix
./nginx.nix

53
services/mailman3.nix Normal file
View file

@ -0,0 +1,53 @@
{ config, lib, ... }:
with lib;
let
cfg = config.machine;
in mkIf (elem "mailman3" config.machine.services) {
services.mailman = {
enable = true;
hyperkittyApiKey = (fileContents "${cfg.secretPath}/hyperkittyApiKey");
hyperkittyBaseUrl = (findFirst (s: s.service == "hyperkitty") cfg cfg.vHosts).domain;
siteOwner = "postmaster@${cfg.domain}";
# webHosts = [];
};
services.uwsgi = {
enable = true;
plugins = [ "python3" ];
user = "nginx";
group = "nginx";
instance = {
type = "emperor";
vassals = {
mailman-web = {
type = "normal";
plugin = "python3";
pythonPackages = self: with self; [
django-mailman3 postorius
];
# module = "mailman-web.wsgi";
socket = "${config.services.uwsgi.runDir}/mailman-web.sock";
wsgi-file = "wsgi.py";
chdir = config.services.mailman.webRoot;
logger = "file:/var/log/uwsgi/mailman-web-error.log";
};
};
};
};
# have to override some stuff because whoever wrote the submodule didn't think about shit when he/she wrote it >.<
# TODO:
# - write a PR for nixpkgs to fix this stuff
# - /var/lib/mailman-web does not exist by default, should be added by the submodule
# - the API key should not be public (even for local users (even worse if your store is public (in case of hosting a binary cache)))
systemd.services.mailman-web.serviceConfig.User = mkForce "nginx";
systemd.services.hyperkitty.serviceConfig.User = mkForce "nginx";
systemd.services.hyperkitty-minutely.serviceConfig.User = mkForce "nginx";
systemd.services.hyperkitty-quarter-hourly.serviceConfig.User = mkForce "nginx";
systemd.services.hyperkitty-hourly.serviceConfig.User = mkForce "nginx";
systemd.services.hyperkitty-daily.serviceConfig.User = mkForce "nginx";
systemd.services.hyperkitty-weekly.serviceConfig.User = mkForce "nginx";
systemd.services.hyperkitty-yearly.serviceConfig.User = mkForce "nginx";
}

View file

@ -0,0 +1,9 @@
{ config, lib, ... }:
with lib;
{
vHost = {
root = "/var/www";
};
}.vHost

View file

@ -0,0 +1,17 @@
{ pkgs, config, lib, ... }:
with lib;
{
vHost = if config.services.mailman.enable then {
locations = {
"/static/".extraConfig = ''
alias /var/lib/mailman-web;
'';
"/".extraConfig = ''
uwsgi_pass unix://${config.services.uwsgi.runDir}/mailman-web.sock;
include ${pkgs.nginx}/conf/uwsgi_params;
'';
};
} else {};
}.vHost