2018-06-04 13:04:16 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.offlineimap;
|
|
|
|
in {
|
|
|
|
|
|
|
|
options.services.offlineimap = {
|
|
|
|
enable = mkEnableOption "Offlineimap, a software to dispose your mailbox(es) as a local Maildir(s).";
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.offlineimap;
|
|
|
|
defaultText = "pkgs.offlineimap";
|
|
|
|
description = "Offlineimap derivation to use.";
|
|
|
|
};
|
|
|
|
|
|
|
|
path = mkOption {
|
|
|
|
type = types.listOf types.path;
|
|
|
|
default = [];
|
2021-10-23 15:05:52 +02:00
|
|
|
example = literalExpression "[ pkgs.pass pkgs.bash pkgs.notmuch ]";
|
2018-06-04 13:04:16 +02:00
|
|
|
description = "List of derivations to put in Offlineimap's path.";
|
|
|
|
};
|
|
|
|
|
|
|
|
startInterval = mkOption {
|
|
|
|
type = types.nullOr types.int;
|
2018-06-05 10:55:01 +02:00
|
|
|
default = 300;
|
2018-06-04 13:04:16 +02:00
|
|
|
description = "Optional key to start offlineimap services each N seconds";
|
|
|
|
};
|
|
|
|
|
|
|
|
runQuick = mkOption {
|
2018-06-05 10:55:01 +02:00
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2018-06-04 13:04:16 +02:00
|
|
|
description = ''
|
|
|
|
Run only quick synchronizations.
|
|
|
|
Ignore any flag updates on IMAP servers. If a flag on the remote IMAP changes, and we have the message locally, it will be left untouched in a quick run.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
description = "Additional text to be appended to <filename>offlineimaprc</filename>.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
environment.etc."offlineimaprc".text = cfg.extraConfig;
|
|
|
|
launchd.user.agents.offlineimap = {
|
|
|
|
path = [ cfg.package ];
|
2018-06-21 21:48:06 +02:00
|
|
|
command = "${cfg.package}/bin/offlineimap -c /etc/offlineimaprc" + optionalString (cfg.runQuick) " -q";
|
2018-06-04 13:04:16 +02:00
|
|
|
serviceConfig.KeepAlive = false;
|
|
|
|
serviceConfig.RunAtLoad = true;
|
|
|
|
serviceConfig.StartInterval = cfg.startInterval;
|
|
|
|
serviceConfig.StandardErrorPath = "/var/log/offlineimap.log";
|
|
|
|
serviceConfig.StandardOutPath = "/var/log/offlineimap.log";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|