From e6ed60548397627bf10f561f9438201dbba0a36e Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Sun, 21 Apr 2024 02:15:42 +0300 Subject: 2024-04-21 --- modules/profiles/email.nix | 125 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 modules/profiles/email.nix (limited to 'modules/profiles/email.nix') diff --git a/modules/profiles/email.nix b/modules/profiles/email.nix new file mode 100644 index 0000000..b2ef02f --- /dev/null +++ b/modules/profiles/email.nix @@ -0,0 +1,125 @@ +{ + config, + lib, + pkgs, + this, + ... +}: +with lib; +let + cfg = config.nixfiles.modules.profiles.email; +in +{ + options.nixfiles.modules.profiles.email.enable = mkEnableOption "Local Email management" // { + default = this.isHeadful; + }; + + config = mkIf cfg.enable { + nixfiles.modules.gnupg.enable = true; + + hm = { + accounts.email = { + maildirBasePath = "${config.my.home}/doc/mail"; + + accounts = + let + mkAccount = + attrs: + mkMerge [ + { + mbsync = { + enable = true; + create = "both"; + expunge = "both"; + patterns = [ "*" ]; + }; + msmtp.enable = true; + mu.enable = true; + thunderbird = { + enable = true; + settings = id: { + "mail.identity.id_${id}.compose_html" = false; + "mail.identity.id_${id}.reply_on_top" = 0; + }; + }; + } + attrs + ]; + + getPassword = + { + path, + line ? 0, + }: + assert (builtins.isInt line); + concatStringsSep " " ( + [ + (getExe config.hm.programs.password-store.package) + "show" + path + ] + ++ optionals (line > 0) [ + "|" + (getExe pkgs.gnused) + "-e" + "'${toString line}!d'" + ] + ); + in + { + shire = mkAccount rec { + address = my.email; + aliases = [ + address + "frodo@rohan.net" + "azahi@shire.net" + ]; + realName = my.fullname; + gpg = { + inherit (my.pgp) key; + signByDefault = false; + encryptByDefault = false; + }; + + primary = true; + + imap = { + host = "shire.net"; + port = 993; + tls.enable = true; + }; + smtp = { + host = "shire.net"; + port = 465; + tls.enable = true; + }; + userName = "azahi@shire.net"; + passwordCommand = getPassword { path = "email/shire.net/azahi"; }; + }; + + yahoo = mkAccount rec { + address = "admin@yahoo.com"; + aliases = [ + address + "admin@yahoo.com" + ]; + realName = "Firstname Lastname"; + + flavor = "yahoo.com"; + userName = "admin@yahoo.com"; + passwordCommand = getPassword { + path = "email/yahoo.com/admin"; + line = 2; + }; + }; + }; + }; + + programs = { + mbsync.enable = true; + msmtp.enable = true; + mu.enable = true; + }; + }; + }; +} -- cgit 1.4.1