2014-09-26 09:03:29 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.mailpile;
|
|
|
|
|
|
|
|
hostname = cfg.hostname;
|
|
|
|
port = cfg.port;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.mailpile = {
|
2020-04-20 19:05:26 +01:00
|
|
|
enable = mkEnableOption "Mailpile the mail client";
|
|
|
|
|
2014-09-26 09:03:29 +01:00
|
|
|
hostname = mkOption {
|
|
|
|
default = "localhost";
|
|
|
|
description = "Listen to this hostname or ip.";
|
|
|
|
};
|
|
|
|
port = mkOption {
|
|
|
|
default = "33411";
|
|
|
|
description = "Listen on this port.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.mailpile.enable {
|
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
users.users.mailpile =
|
2014-09-26 09:03:29 +01:00
|
|
|
{ uid = config.ids.uids.mailpile;
|
|
|
|
description = "Mailpile user";
|
|
|
|
createHome = true;
|
|
|
|
home = "/var/lib/mailpile";
|
|
|
|
};
|
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
users.groups.mailpile =
|
2014-09-26 09:03:29 +01:00
|
|
|
{ gid = config.ids.gids.mailpile;
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.mailpile =
|
|
|
|
{
|
|
|
|
description = "Mailpile server.";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
User = "mailpile";
|
|
|
|
ExecStart = "${pkgs.mailpile}/bin/mailpile --www ${hostname}:${port} --wait";
|
|
|
|
# mixed - first send SIGINT to main process,
|
|
|
|
# then after 2min send SIGKILL to whole group if neccessary
|
|
|
|
KillMode = "mixed";
|
|
|
|
KillSignal = "SIGINT"; # like Ctrl+C - safe mailpile shutdown
|
|
|
|
TimeoutSec = 120; # wait 2min untill SIGKILL
|
|
|
|
};
|
|
|
|
environment.MAILPILE_HOME = "/var/lib/mailpile/.local/share/Mailpile";
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.mailpile ];
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|