diff options
author | Katharina Fey <kookie@spacekookie.de> | 2020-02-03 10:05:30 +0100 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2020-02-03 10:05:30 +0100 |
commit | c488527c95c874d3b8743c915173ad7bfb05d5af (patch) | |
tree | 2b874dc5606a9dff44096a5e8557f00dc52ac2b6 /home-manager/modules/programs/getmail.nix | |
parent | 899a451e08f7d6d2c8214d119c2a0316849a0ed4 (diff) | |
parent | 6cc4fd6ede4909226cb81d3475834251ed1b7210 (diff) |
Merge commit '6cc4fd6ede4909226cb81d3475834251ed1b7210'
Diffstat (limited to 'home-manager/modules/programs/getmail.nix')
-rw-r--r-- | home-manager/modules/programs/getmail.nix | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/home-manager/modules/programs/getmail.nix b/home-manager/modules/programs/getmail.nix index 04a958d6cda..2c3919dcf2f 100644 --- a/home-manager/modules/programs/getmail.nix +++ b/home-manager/modules/programs/getmail.nix @@ -4,34 +4,33 @@ with lib; let - accounts = filter (a: a.getmail.enable) - (attrValues config.accounts.email.accounts); + accounts = + filter (a: a.getmail.enable) (attrValues config.accounts.email.accounts); - renderAccountConfig = account: with account; + renderAccountConfig = account: + with account; let passCmd = concatMapStringsSep ", " (x: "'${x}'") passwordCommand; - renderedMailboxes = concatMapStringsSep ", " (x: "'${x}'") getmail.mailboxes; - retrieverType = if imap.tls.enable - then "SimpleIMAPSSLRetriever" - else "SimpleIMAPRetriever"; - destination = if getmail.destinationCommand != null - then - { - destinationType = "MDA_external"; - destinationPath = getmail.destinationCommand; - } - else - { - destinationType = "Maildir"; - destinationPath = "${maildir.absPath}/"; - }; + renderedMailboxes = + concatMapStringsSep ", " (x: "'${x}'") getmail.mailboxes; + retrieverType = if imap.tls.enable then + "SimpleIMAPSSLRetriever" + else + "SimpleIMAPRetriever"; + destination = if getmail.destinationCommand != null then { + destinationType = "MDA_external"; + destinationPath = getmail.destinationCommand; + } else { + destinationType = "Maildir"; + destinationPath = "${maildir.absPath}/"; + }; renderGetmailBoolean = v: if v then "true" else "false"; in '' # Generated by Home-Manager. [retriever] type = ${retrieverType} server = ${imap.host} - ${optionalString (imap.port != null) "port = ${imap.port}"} + ${optionalString (imap.port != null) "port = ${toString imap.port}"} username = ${userName} password_command = (${passCmd}) mailboxes = ( ${renderedMailboxes} ) @@ -46,15 +45,13 @@ let ''; getmailEnabled = length (filter (a: a.getmail.enable) accounts) > 0; # Watch out! This is used by the getmail.service too! - renderConfigFilepath = a: ".getmail/getmail${if a.primary then "rc" else a.name}"; -in - - { - config = mkIf getmailEnabled { - home.file = map (a: - { target = renderConfigFilepath a; - text = renderAccountConfig a; - }) accounts; - - }; - } + renderConfigFilepath = a: + ".getmail/getmail${if a.primary then "rc" else a.name}"; + +in { + config = mkIf getmailEnabled { + home.file = foldl' (a: b: a // b) { } + (map (a: { "${renderConfigFilepath a}".text = renderAccountConfig a; }) + accounts); + }; +} |