From 182ec2a4dbdf20c87cdcf86cc2d816d0fc62fa13 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 22 May 2021 16:04:46 +0200 Subject: [PATCH] home: add mail and accounts configuration --- home/default.nix | 1 + home/mail/accounts.nix | 95 ++++++++++++++++++++++++++++++++++++++++++ home/mail/default.nix | 12 ++++++ 3 files changed, 108 insertions(+) create mode 100644 home/mail/accounts.nix create mode 100644 home/mail/default.nix diff --git a/home/default.nix b/home/default.nix index ddbf1ca..8b638aa 100644 --- a/home/default.nix +++ b/home/default.nix @@ -14,6 +14,7 @@ ./gtk.nix ./htop.nix ./jq.nix + ./mail ./mpv.nix ./nix-index.nix ./nm-applet.nix diff --git a/home/mail/accounts.nix b/home/mail/accounts.nix new file mode 100644 index 0000000..8a3e1eb --- /dev/null +++ b/home/mail/accounts.nix @@ -0,0 +1,95 @@ +{ lib, pkgs, ... }: +let + mkAddress = address: domain: "${address}@${domain}"; + + mkConfig = { domain, address, passName, aliases ? [ ], primary ? false }: { + realName = lib.mkDefault "Bruno BELANYI"; + userName = lib.mkDefault (mkAddress address domain); + passwordCommand = + lib.mkDefault [ "${pkgs.ambroisie.bw-pass}/bin/bw-pass" "Mail" passName ]; + + address = mkAddress address domain; + aliases = builtins.map (lib.flip mkAddress domain) aliases; + + inherit primary; + }; + + migaduConfig = { + imap = { + host = "imap.migadu.com"; + port = 993; + tls = { + enable = true; + }; + }; + smtp = { + host = "smtp.migadu.com"; + port = 465; + tls = { + enable = true; + }; + }; + }; + + gmailConfig = { + flavor = "gmail.com"; + folders = { + drafts = "[Gmail]/Drafts"; + sent = "[Gmail]/Sent Mail"; + trash = "[Gmail]/Trash"; + }; + }; + + office365Config = { + imap = { + host = "outlook.office365.com"; + port = 993; + tls = { + enable = true; + }; + }; + smtp = { + host = "outlook.office365.com"; + port = 587; + tls = { + enable = true; + useStartTls = true; + }; + }; + }; +in +{ + config.accounts.email.accounts = { + personal = lib.mkMerge [ + # Common configuraton + (mkConfig { + domain = "belanyi.fr"; + address = "bruno"; + passName = "Migadu"; + aliases = [ "admin" "postmaster" ]; + primary = true; # This is my primary email + }) + migaduConfig + ]; + + gmail = lib.mkMerge [ + # Common configuraton + (mkConfig { + domain = "gmail.com"; + address = "brunobelanyi"; + passName = "GMail"; + }) + gmailConfig + ]; + + epita = lib.mkMerge [ + # Common configuration + (mkConfig { + domain = "epita.fr"; + address = "bruno.belanyi"; + passName = "EPITA"; + }) + office365Config + ]; + }; +} diff --git a/home/mail/default.nix b/home/mail/default.nix new file mode 100644 index 0000000..32c918e --- /dev/null +++ b/home/mail/default.nix @@ -0,0 +1,12 @@ +{ config, lib, ... }: +{ + imports = [ + ./accounts.nix + ]; + + config = { + accounts.email = { + maildirBasePath = "mail"; + }; + }; +}