dotfiles/modules/common/mail/default.nix

93 lines
2.6 KiB
Nix
Raw Normal View History

2022-10-30 17:57:14 +00:00
{ config, pkgs, lib, ... }: {
imports = [ ./himalaya.nix ./aerc.nix ];
options = {
2022-12-22 00:31:25 +00:00
mail.enable = lib.mkEnableOption "Mail service.";
2022-12-21 21:18:03 +00:00
mail.user = lib.mkOption {
2022-10-30 17:57:14 +00:00
type = lib.types.str;
description = "User name for the email address.";
default = config.user;
};
2022-12-21 21:18:03 +00:00
mail.server = lib.mkOption {
2023-03-12 21:07:41 +00:00
type = lib.types.nullOr lib.types.str;
2022-10-30 17:57:14 +00:00
description = "Server name for the email address.";
};
2023-03-12 21:07:41 +00:00
mail.imapHost = lib.mkOption {
type = lib.types.nullOr lib.types.str;
description = "Server host for IMAP (reading mail).";
};
mail.smtpHost = lib.mkOption {
type = lib.types.nullOr lib.types.str;
description = "Server host for SMTP (sending mail).";
};
2022-10-30 17:57:14 +00:00
};
2022-12-22 00:31:25 +00:00
config = lib.mkIf config.mail.enable {
2022-10-30 17:57:14 +00:00
home-manager.users.${config.user} = {
programs.mbsync = { enable = true; };
services.mbsync = lib.mkIf pkgs.stdenv.isLinux {
enable = true;
frequency = "*:0/5";
};
accounts.email = {
maildirBasePath = "${config.homePath}/mail";
accounts = {
2022-12-21 21:18:03 +00:00
home = let address = "${config.mail.user}@${config.mail.server}";
2022-10-30 17:57:14 +00:00
in {
userName = address;
realName = config.fullName;
primary = true;
inherit address;
2022-12-21 21:18:03 +00:00
aliases = map (user: "${user}@${config.mail.server}") [
2022-10-30 17:57:14 +00:00
"me"
"hey"
"admin"
];
alot = { };
flavor = "plain";
folders = { };
getmail = { };
imap = {
2023-03-12 21:07:41 +00:00
host = config.mail.imapHost;
2022-10-30 17:57:14 +00:00
port = 993;
tls.enable = true;
};
imapnotify = {
enable = false;
boxes = [ ];
onNotify = "";
onNotifyPost = "";
};
maildir = { path = "main"; };
mbsync = {
enable = true;
2023-03-12 21:07:41 +00:00
create = "both";
expunge = "both";
remove = "both";
2022-10-30 17:57:14 +00:00
patterns = [ "*" ];
extraConfig.channel = {
CopyArrivalDate = "yes"; # Sync time of original message
};
};
mu.enable = false;
notmuch.enable = false;
passwordCommand =
"${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${
2023-03-05 14:05:45 +00:00
builtins.toString ../../../private/mailpass.age
2022-10-30 17:57:14 +00:00
}";
smtp = {
2023-03-12 21:07:41 +00:00
host = config.mail.smtpHost;
2022-10-30 17:57:14 +00:00
port = 465;
tls.enable = true;
};
};
};
};
};
};
}