{ config, ... }: let account = config.repo.account; in { flake.modules.homeManager.email = { config, lib, ... }: let mkOffice365Account = { address, primary, ... }: { enable = true; inherit address primary; realName = account.realName; userName = address; thunderbird = { enable = true; settings = id: { "mail.smtpserver.smtp_${id}.authMethod" = 10; "mail.server.server_${id}.authMethod" = 10; }; }; flavor = "outlook.office365.com"; }; mkMxrouteAccount = { address, primary, ... }: { enable = true; inherit address primary; realName = account.realName; userName = address; thunderbird.enable = true; imap = { authentication = "plain"; host = "taylor.mxrouting.net"; port = 993; tls.enable = true; }; smtp = { authentication = "plain"; host = "taylor.mxrouting.net"; port = 465; tls.enable = true; }; }; mkEmailAccount = email: if email.type == "office365" then mkOffice365Account email else if email.type == "mxrouting" then mkMxrouteAccount email else throw "Unsupported email type `${email.type}` for ${config.home.username}"; in { programs.thunderbird = { enable = true; profiles.${config.home.username} = { isDefault = true; withExternalGnupg = true; settings = { "mail.ui.display.message_pane_vertical" = true; "mail.ui.display.thread_pane_view_type" = "cards"; "mail.uidensity" = 1; "privacy.donottrackheader.enabled" = true; "mail.server.server2.hidden" = true; "mailnews.start_page.enabled" = false; "mail.provider.enabled" = false; "layout.css.devPixelsPerPx" = 0.85; }; }; }; accounts.email.accounts = lib.mapAttrs (_: mkEmailAccount) account.emails; }; }