stockholm/krebs/3modules/exim.nix

85 lines
2.3 KiB
Nix
Raw Normal View History

2016-10-20 18:54:38 +00:00
{ config, lib, pkgs, ... }: with import <stockholm/lib>; let
2016-04-26 23:10:25 +00:00
cfg = config.krebs.exim;
in {
options.krebs.exim = {
enable = mkEnableOption "krebs.exim";
config = mkOption {
type = types.str;
default = "";
description = ''
Verbatim Exim configuration. This should not contain exim_user,
exim_group, exim_path, or spool_directory.
'';
};
user = mkOption {
type = types.user;
default = {
name = "exim";
home = "/var/spool/exim";
2016-04-26 23:03:47 +00:00
};
2016-04-26 23:10:25 +00:00
description = ''
User to use when no root privileges are required.
In particular, this applies when receiving messages and when doing
remote deliveries. (Local deliveries run as various non-root users,
typically as the owner of a local mailbox.) Specifying this value
as root is not supported.
'';
};
group = mkOption {
type = types.group;
default = {
name = "exim";
2016-04-26 23:03:47 +00:00
};
2016-04-26 23:10:25 +00:00
description = ''
Group to use when no root privileges are required.
'';
2016-04-26 23:03:47 +00:00
};
};
2016-04-26 23:10:25 +00:00
config = lib.mkIf cfg.enable {
2016-04-26 23:03:47 +00:00
environment = {
etc."exim.conf".source = pkgs.writeEximConfig "exim.conf" ''
2016-04-26 23:10:25 +00:00
exim_user = ${cfg.user.name}
exim_group = ${cfg.group.name}
exim_path = /run/wrappers/bin/exim
2016-04-26 23:10:25 +00:00
spool_directory = ${cfg.user.home}
2017-11-25 14:40:45 +00:00
# https://lists.exim.org/lurker/message/20171125.034842.d1d75cac.en.html
chunking_advertise_hosts =
2016-04-26 23:03:47 +00:00
${cfg.config}
'';
2016-04-26 23:10:25 +00:00
systemPackages = [ pkgs.exim ];
2016-04-26 23:03:47 +00:00
};
2016-04-26 23:10:25 +00:00
krebs.setuid = {
exim = {
filename = "${pkgs.exim}/bin/exim";
mode = "4111";
};
sendmail = {
filename = "${pkgs.exim}/bin/exim";
mode = "4111";
};
2016-04-26 23:03:47 +00:00
};
systemd.services.exim = {
2016-04-26 23:10:25 +00:00
restartTriggers = [
config.environment.etc."exim.conf".source
];
2016-04-26 23:03:47 +00:00
serviceConfig = {
2016-04-26 23:10:25 +00:00
ExecStart = "${pkgs.exim}/bin/exim -bdf -q30m";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
};
wantedBy = [ "multi-user.target" ];
};
users = {
groups.${cfg.group.name} = {
inherit (cfg.group) name gid;
};
users.${cfg.user.name} = {
inherit (cfg.user) home name uid;
createHome = true;
group = cfg.group.name;
2016-04-26 23:03:47 +00:00
};
};
};
}