Files
Foundry/home/gabriel/features/productivity/accounts/mgc.nix
T

101 lines
2.4 KiB
Nix

{config, lib, ...}: let
realName = "Gabriel Fontes";
address = "${lib.toLower (lib.replaceString " " "." realName)}@magalu.cloud";
commonChannelCfg = {
Expunge = "Both"; # Sync deleted messages
Create = "Both"; # Create mailboxes if needed
Remove = "None"; # Don't ever delete mailboxes
SyncState = "*"; # Ensure sync state is in mail dir
};
gmailChannels = {
Inbox = {
farPattern = "INBOX";
nearPattern = "Inbox";
extraConfig = commonChannelCfg;
};
Archive = {
farPattern = "Archived Mail";
nearPattern = "Archive";
extraConfig = commonChannelCfg;
};
Junk = {
farPattern = "[Gmail]/Spam";
nearPattern = "Junk";
extraConfig = commonChannelCfg;
};
Trash = {
farPattern = "[Gmail]/Trash";
nearPattern = "Trash";
extraConfig = commonChannelCfg;
};
Drafts = {
farPattern = "[Gmail]/Drafts";
nearPattern = "Drafts";
extraConfig = commonChannelCfg;
};
Sent = {
farPattern = "[Gmail]/Sent Mail";
nearPattern = "Sent";
extraConfig = commonChannelCfg;
};
};
oama = lib.getExe config.programs.oama.package;
in {
accounts = {
email.accounts.mgc = {
inherit address realName;
flavor = "gmail.com";
userName = address;
passwordCommand = "${oama} access ${address}";
mbsync = {
enable = true;
groups.mgc.channels = gmailChannels;
extraConfig = {
channel = commonChannelCfg; # TODO: check if I really need this one
account.AuthMechs = "XOAUTH2";
};
};
msmtp = {
extraConfig.auth = "oauthbearer";
enable = true;
};
folders.sent = null;
aerc = {
enable = true;
# Pinned at the top of the sidebar, in this order; the rest stays
# alphabetical
extraAccounts.folders-sort = [
"Inbox"
"Archive"
"Drafts"
"Sent"
"Junk"
"Trash"
];
};
};
calendar.accounts.mgc = {
primaryCollection = address;
khal = {
enable = true;
addresses = [address];
type = "discover";
};
remote = {
type = "google_calendar";
};
vdirsyncer = {
enable = true;
metadata = ["color" "displayname"];
collections = ["from a" "from b"];
accessTokenCommand = [oama "access" address];
};
};
};
}