1 { config, lib, pkgs, ... }:
7 cfg = config.services.davmail;
9 configType = with types;
10 oneOf [ (attrsOf configType) str int bool ] // {
11 description = "davmail config type (str, int, bool or attribute set thereof)";
14 toStr = val: if isBool val then boolToString val else toString val;
16 linesForAttrs = attrs: concatMap (name: let value = attrs.${name}; in
18 then map (line: name + "." + line) (linesForAttrs value)
19 else [ "${name}=${toStr value}" ]
22 configFile = pkgs.writeText "davmail.properties" (concatStringsSep "\n" (linesForAttrs cfg.config));
27 options.services.davmail = {
28 enable = mkEnableOption (lib.mdDoc "davmail, an MS Exchange gateway");
32 description = lib.mdDoc "Outlook Web Access URL to access the exchange server, i.e. the base webmail URL.";
33 example = "https://outlook.office365.com/EWS/Exchange.asmx";
39 description = lib.mdDoc ''
40 Davmail configuration. Refer to
41 <http://davmail.sourceforge.net/serversetup.html>
42 and <http://davmail.sourceforge.net/advanced.html>
43 for details on supported values.
45 example = literalExpression ''
47 davmail.allowRemote = true;
48 davmail.imapPort = 55555;
49 davmail.bindAddress = "10.0.1.2";
50 davmail.smtpSaveInSent = true;
51 davmail.folderSizeLimit = 10;
52 davmail.caldavAutoSchedule = false;
53 log4j.logger.rootLogger = "DEBUG";
59 config = mkIf cfg.enable {
61 services.davmail.config = {
62 davmail = mapAttrs (name: mkDefault) {
64 disableUpdateCheck = true;
65 logFilePath = "/var/log/davmail/davmail.log";
76 logger.davmail = mkDefault "WARN";
77 logger.httpclient.wire = mkDefault "WARN";
78 logger.org.apache.commons.httpclient = mkDefault "WARN";
79 rootLogger = mkDefault "WARN";
83 systemd.services.davmail = {
84 description = "DavMail POP/IMAP/SMTP Exchange Gateway";
85 after = [ "network.target" ];
86 wantedBy = [ "multi-user.target" ];
90 ExecStart = "${pkgs.davmail}/bin/davmail ${configFile}";
91 Restart = "on-failure";
93 LogsDirectory = "davmail";
97 environment.systemPackages = [ pkgs.davmail ];