Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d81b51ac02ff
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6ad76ff1ba73
Choose a head ref
  • 2 commits
  • 2 files changed
  • 3 contributors

Commits on Mar 9, 2019

  1. nixos/davmail: init

    Co-authored-by: Aaron Andersen <aaron@fosslib.net>
    Co-authored-by: Silvan Mosberger <infinisil@icloud.com>
    3 people authored and Sean Haugh committed Mar 9, 2019
    1
    Copy the full SHA
    f2730d8 View commit details
  2. Merge pull request #52096 from furrycatherder/davmail

    nixos/davmail: init
    infinisil authored Mar 9, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6ad76ff View commit details
Showing with 92 additions and 0 deletions.
  1. +1 −0 nixos/modules/module-list.nix
  2. +91 −0 nixos/modules/services/mail/davmail.nix
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
@@ -340,6 +340,7 @@
./services/logging/syslog-ng.nix
./services/logging/syslogd.nix
./services/mail/clamsmtp.nix
./services/mail/davmail.nix
./services/mail/dkimproxy-out.nix
./services/mail/dovecot.nix
./services/mail/dspam.nix
91 changes: 91 additions & 0 deletions nixos/modules/services/mail/davmail.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{ config, lib, pkgs, ... }:

with lib;

let

cfg = config.services.davmail;

configType = with types;
either (either (attrsOf configType) str) (either int bool) // {
description = "davmail config type (str, int, bool or attribute set thereof)";
};

toStr = val: if isBool val then boolToString val else toString val;

linesForAttrs = attrs: concatMap (name: let value = attrs.${name}; in
if isAttrs value
then map (line: name + "." + line) (linesForAttrs value)
else [ "${name}=${toStr value}" ]
) (attrNames attrs);

configFile = pkgs.writeText "davmail.properties" (concatStringsSep "\n" (linesForAttrs cfg.config));

in

{
options.services.davmail = {
enable = mkEnableOption "davmail, an MS Exchange gateway";

url = mkOption {
type = types.str;
description = "Outlook Web Access URL to access the exchange server, i.e. the base webmail URL.";
example = "https://outlook.office365.com/EWS/Exchange.asmx";
};

config = mkOption {
type = configType;
default = {};
description = ''
Davmail configuration. Refer to
<link xlink:href="http://davmail.sourceforge.net/serversetup.html"/>
and <link xlink:href="http://davmail.sourceforge.net/advanced.html"/>
for details on supported values.
'';
example = literalExample ''
{
davmail.allowRemote = true;
davmail.imapPort = 55555;
davmail.bindAddress = "10.0.1.2";
davmail.smtpSaveInSent = true;
davmail.folderSizeLimit = 10;
davmail.caldavAutoSchedule = false;
log4j.logger.rootLogger = "DEBUG";
}
'';
};
};

config = mkIf cfg.enable {

services.davmail.config.davmail = mapAttrs (name: mkDefault) {
server = true;
disableUpdateCheck = true;
logFilePath = "/var/log/davmail/davmail.log";
logFileSize = "1MB";
mode = "auto";
url = cfg.url;
caldavPort = 1080;
imapPort = 1143;
ldapPort = 1389;
popPort = 1110;
smtpPort = 1025;
};

systemd.services.davmail = {
description = "DavMail POP/IMAP/SMTP Exchange Gateway";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];

serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.davmail}/bin/davmail ${configFile}";
Restart = "on-failure";
DynamicUser = "yes";
LogsDirectory = "davmail";
};
};

environment.systemPackages = [ pkgs.davmail ];
};
}