1 { config, lib, pkgs, ... }:
4 inherit (lib) literalExpression mkIf mkOption singleton types mkPackageOption;
5 inherit (pkgs) coreutils;
6 cfg = config.services.exim;
20 description = "Whether to enable the Exim mail transfer agent.";
27 Verbatim Exim configuration. This should not contain exim_user,
28 exim_group, exim_path, or spool_directory.
36 User to use when no root privileges are required.
37 In particular, this applies when receiving messages and when doing
38 remote deliveries. (Local deliveries run as various non-root users,
39 typically as the owner of a local mailbox.) Specifying this value
40 as root is not supported.
48 Group to use when no root privileges are required.
54 default = "/var/spool/exim";
56 Location of the spool directory of exim.
60 package = mkPackageOption pkgs "exim" {
62 This can be used to enable features such as LDAP or PAM support.
66 queueRunnerInterval = mkOption {
70 How often to spawn a new queue runner.
80 config = mkIf cfg.enable {
83 etc."exim.conf".text = ''
84 exim_user = ${cfg.user}
85 exim_group = ${cfg.group}
86 exim_path = /run/wrappers/bin/exim
87 spool_directory = ${cfg.spoolDir}
90 systemPackages = [ cfg.package ];
93 users.users.${cfg.user} = {
94 description = "Exim mail transfer agent user";
95 uid = config.ids.uids.exim;
99 users.groups.${cfg.group} = {
100 gid = config.ids.gids.exim;
103 security.wrappers.exim =
107 source = "${cfg.package}/bin/exim";
110 systemd.services.exim = {
111 description = "Exim Mail Daemon";
112 wantedBy = [ "multi-user.target" ];
113 restartTriggers = [ config.environment.etc."exim.conf".source ];
115 ExecStart = "!${cfg.package}/bin/exim -bdf -q${cfg.queueRunnerInterval}";
116 ExecReload = "!${coreutils}/bin/kill -HUP $MAINPID";
120 if ! test -d ${cfg.spoolDir}; then
121 ${coreutils}/bin/mkdir -p ${cfg.spoolDir}
122 ${coreutils}/bin/chown ${cfg.user}:${cfg.group} ${cfg.spoolDir}