3
0
Fork 0
forked from mirrors/nixpkgs

nixos/dovecot: added configFile option and default Restart on-failure, PR #5845

Absolute path is required when one has such postfix configuration
where he/she needs to specify the actual (real) path to active dovecot
config.

Without this commit applied, the dovecot is running in such way:
/nix/store/hashAAA-dovecot-ver/sbin/dovecot -F -c /nix/store/hashBBB-dovecot2.conf

and postfix can't be aware of the value of "hashBBB" via services.postfix.extraConfig = '' ... '';
(it can only be aware of "hashAAA" with ${pkgs.dovecot} parameter)

Also enable Restart on-failure.

Edit: set RestartSec to 1s
This commit is contained in:
Andrey Arapov 2015-01-19 10:45:20 +01:00 committed by Luca Bruno
parent c163baca3b
commit 04be7262a6

View file

@ -45,8 +45,6 @@ let
pop3_uidl_format = %08Xv%08Xu
'' + cfg.extraConfig;
confFile = pkgs.writeText "dovecot.conf" dovecotConf;
in
{
@ -88,6 +86,12 @@ in
description = "Additional entries to put verbatim into Dovecot's config file.";
};
configFile = mkOption {
default = null;
description = "Config file used for the whole dovecot configuration.";
apply = v: if v != null then v else pkgs.writeText "dovecot.conf" dovecotConf;
};
mailLocation = mkOption {
default = "maildir:/var/spool/mail/%u"; /* Same as inbox, as postfix */
example = "maildir:~/mail:INBOX=/var/spool/mail/%u";
@ -144,10 +148,11 @@ in
gid = config.ids.gids.dovecot2;
};
jobs.dovecot2 =
systemd.services.dovecot2 =
{ description = "Dovecot IMAP/POP3 server";
startOn = "started networking";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
preStart =
''
@ -155,7 +160,13 @@ in
${pkgs.coreutils}/bin/chown -R ${cfg.user}:${cfg.group} /var/run/dovecot2
'';
exec = "${pkgs.dovecot}/sbin/dovecot -F -c ${confFile}";
serviceConfig = {
ExecStart = "${pkgs.dovecot}/sbin/dovecot -F -c ${cfg.configFile}";
Restart = "on-failure";
RestartSec = "1s";
StartLimitInterval = "1min";
};
};
environment.systemPackages = [ pkgs.dovecot ];