mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 14:54:29 +01:00
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:
parent
c163baca3b
commit
04be7262a6
1 changed files with 16 additions and 5 deletions
|
@ -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 ];
|
||||
|
|
Loading…
Reference in a new issue