Skip to content

Commit

Permalink
Email config
Browse files Browse the repository at this point in the history
  • Loading branch information
DanNixon committed Oct 5, 2023
1 parent 668c355 commit 5071654
Show file tree
Hide file tree
Showing 7 changed files with 327 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .sops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ keys:
- &maya age1w908m223s5xg3xmsm3zxwxcudryc4hcp8xk5kveq09kgupjtpqhqq4nqsd

creation_rules:
- path_regex: home-manager/common/email/secrets.nix
key_groups:
- pgp:
- *dan

- path_regex: nixos/common/dan/secrets/secrets.yaml
key_groups:
- pgp:
Expand Down
110 changes: 110 additions & 0 deletions home-manager/common/email/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
inputs,
config,
pkgs,
...
}: let
secrets = import ./secrets.nix;
in {
imports = [
./neomutt.nix
];

programs.mbsync.enable = true;
programs.msmtp.enable = true;

accounts.email.maildirBasePath = ".mail";

accounts.email.accounts = {
fastmail = let
a = secrets.accounts.fastmail;
in {
primary = true;

address = a.address;
realName = a.realName;
userName = a.address;
passwordCommand = "pass Passwords/Personal/fastmail/api_password";

imap.host = "imap.fastmail.com";
mbsync = {
enable = true;
create = "both";
};

smtp = {
host = "smtp.fastmail.com";
port = 587;
};
msmtp.enable = true;
};

gmail = let
a = secrets.accounts.gmail;
in {
address = a.address;
realName = a.realName;
userName = a.address;
passwordCommand = "pass Passwords/Personal/google/email_password";

imap.host = "imap.gmail.com";
mbsync = {
enable = true;
create = "both";
patterns = [
"*"
"![Google Mail]/All Mail"
"![Google Mail]/All mail"
];
};

smtp = {
host = "smtp.gmail.com";
port = 587;
};
msmtp.enable = true;
};

outlook-1 = let
a = secrets.accounts.outlook-1;
in {
address = a.address;
realName = a.realName;
userName = a.address;
passwordCommand = "pass Passwords/Personal/microsoft_1/Password";

imap.host = "outlook.office365.com";
mbsync = {
enable = true;
create = "both";
};

smtp = {
host = "smtp.office365.com";
port = 587;
};
msmtp.enable = true;
};

outlook-2 = let
a = secrets.accounts.outlook-2;
in {
address = a.address;
realName = a.realName;
userName = a.address;
passwordCommand = "pass Passwords/Personal/microsoft_2/Password";

imap.host = "outlook.office365.com";
mbsync = {
enable = true;
create = "both";
};

smtp = {
host = "smtp.office365.com";
port = 587;
};
msmtp.enable = true;
};
};
}
185 changes: 185 additions & 0 deletions home-manager/common/email/neomutt.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
{
config,
pkgs,
lib,
...
}: let
secrets = import ./secrets.nix;
in {
home.packages = with pkgs; [
neomutt
w3m
];

xdg.configFile."neomutt/neomuttrc".text = ''
set editor = "$EDITOR"
set mbox_type = Maildir
set edit_headers
set mime_type_query_command = 'xdg-mime query filetype'
set sort = 'reverse-date'
set fast_reply # skip to compose when replying
set fcc_attach # save attachments with the body
set forward_format = 'Fwd: %s' # format of subject when forwarding
set forward_quote # include message in forwards
set reverse_name # reply as whomever it was to
set include # include message in replies
set mark_old = no # Unread mail stay unread until read
set mime_forward = yes # attachments are forwarded with mail
set rfc2047_parameters = yes
set date_format = "%Y-%m-%d"
set index_format = "%4C %Z %d %-25.25L %s"
auto_view text/html
alternative_order text/plain text/enriched text/html
# Sidebar
set sidebar_visible = yes
set sidebar_next_new_wrap = yes
set sidebar_short_path = yes
set sidebar_delim_chars = '/'
set sidebar_folder_indent = yes
set sidebar_indent_string = ' '
set mail_check_stats
set sidebar_format = '%B%?F? [%F]?%* %?N?%N/? %?S?%S?'
bind index,pager K sidebar-prev
bind index,pager J sidebar-next
bind index,pager o sidebar-open
# Default index colors
color index yellow default '.*'
color index_author red default '.*'
color index_number blue default
color index_subject cyan default '.*'
# New mail is boldened
color index brightyellow default "~N"
color index_author brightred default "~N"
color index_subject brightcyan default "~N"
# Tagged mail is highlighted
color index brightyellow blue "~T"
color index_author brightred blue "~T"
color index_subject brightcyan blue "~T"
# Other colors and aesthetic settings
mono bold bold
mono underline underline
mono indicator reverse
mono error bold
color normal default default
color indicator brightblack white
color sidebar_highlight red default
color sidebar_divider brightblack default
color sidebar_flagged red default
color sidebar_new green default
color normal brightyellow default
color error red default
color tilde black default
color message cyan default
color markers red white
color attachment white default
color search brightmagenta default
color status brightyellow default
color hdrdefault brightgreen default
color quoted green default
color quoted1 blue default
color quoted2 cyan default
color quoted3 yellow default
color quoted4 red default
color quoted5 brightred default
color signature brightgreen default
color bold black default
color underline black default
color normal default default
# Mailboxes
set folder = ~/.mail/
set spoolfile = "+local/Inbox"
set record = "+local/Sent"
set trash = "+local/Trash"
set postponed = "+local/Drafts"
mailboxes \
+local \
+local/Inbox \
+local/Sent \
+local/Archive \
+local/Drafts \
+local/Trash
mailboxes ${lib.strings.concatMapStringsSep " " (x: "+local/" + x) secrets.extra-local-mailboxes}
# Account: fastmail
mailboxes \
+fastmail \
+fastmail/Inbox \
+fastmail/Spam
folder-hook \
"+fastmail.*" \
'source ~/${config.xdg.configFile."neomutt/accounts/fastmail".target}'
# Account: gmail
mailboxes \
+gmail \
+gmail/Inbox \
"+gmail/[Google Mail]" \
"+gmail/[Google Mail]/Spam"
folder-hook \
"+gmail.*" \
'source ~/${config.xdg.configFile."neomutt/accounts/gmail".target}'
# Account: outlook-1
mailboxes \
+outlook-1 \
+outlook-1/Inbox \
+outlook-1/Junk
folder-hook \
"+outlook-1.*" \
'source ~/${config.xdg.configFile."neomutt/accounts/outlook-1".target}'
# Account: outlook-2
mailboxes \
+outlook-2 \
+outlook-2/Inbox \
+outlook-2/Junk
folder-hook \
"+outlook-2.*" \
'source ~/${config.xdg.configFile."neomutt/accounts/outlook-2".target}'
'';

xdg.configFile."neomutt/accounts/fastmail".text = let
a = secrets.accounts.fastmail;
in ''
set from = "${a.address}"
set realname = "${a.realName}"
set sendmail = "msmtp -a fastmail"
'';

xdg.configFile."neomutt/accounts/gmail".text = let
a = secrets.accounts.gmail;
in ''
set from = "${a.address}"
set realname = "${a.realName}"
set sendmail = "msmtp -a gmail"
'';

xdg.configFile."neomutt/accounts/outlook-1".text = let
a = secrets.accounts.outlook-1;
in ''
set from = "${a.address}"
set realname = "${a.realName}"
set sendmail = "msmtp -a outlook-1"
'';

xdg.configFile."neomutt/accounts/outlook-2".text = let
a = secrets.accounts.outlook-2;
in ''
set from = "${a.address}"
set realname = "${a.realName}"
set sendmail = "msmtp -a outlook-2"
'';
}
21 changes: 21 additions & 0 deletions home-manager/common/email/secrets.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"data": "ENC[AES256_GCM,data:6bgcX4aRxt6V+XfhpqVf9IcZCYaeQVXFC58EIt/lRyr9wf+y6N/hI0dAZNykTZEC0cljBw2FQjxsMQFJMfrTUF8knUCqnoTaLDTbbChKMG2fgGnJNleST9DGTQjI+KAfTUtYbhgco3YkJUrVHsyYoWou1DMnc2UOgvtOYQTJdJ2Ju9VV3w/BYnbk/Z0Q7qtUCgWQZJCP6v3sP+9NRh0VxMP51YnnrS0Q/RTgdRqvtk9jgkyEyNeo2hjvyqNIj+uhamAYJJ/LBsUFoj6MI7rHcHRUZGcZIJUbs88YIJZNzARJ3uXRTcRRWumohJY/B3gORt7zag6u1/jC6NOvObXKVd2pLJV3CvX56nZE6+0t0REsbAuFeLbKJuwcKcBl5b/rt4+1274QINGAwyLyDFaWHJWvybFPw69qtO6/dUkT7Gz0F2gzFr93I8+ImoM8xaXsa50krvGWGxuDh7GEY8FwX/LLg+47Bf49xnRmwSym2zLgpHjI4eUf2DY5oL1W5LrCjraZEZ0cElNYn5l06jCeHdd50uUN8ZYVQyb10ln/q3nJzhK11xjJ76na56DxfcuBGbj3Nf/LOwwI7t0x3SjjQDJNGis=,iv:ZRSv347oJKO9HW1uHqqKxDY+EcDtWlQGHR92FmeCCug=,tag:UwWDAVITJ9bobjrLwagXIQ==,type:str]",
"sops": {
"kms": null,
"gcp_kms": null,
"azure_kv": null,
"hc_vault": null,
"age": null,
"lastmodified": "2023-09-24T09:29:13Z",
"mac": "ENC[AES256_GCM,data:fmnsakg+uIyeFniEUSIKVPdbF85KeedHEeL/tvmpW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LB4TtBRh65VSwGS8w6yT2y/FPonwBA8zsAFpxUS5tPS5yYsK0nDvJnI=\n=GGSD\n-----END PGP MESSAGE-----\n",
"fp": "84E956241243C35EA286B410EA06B7ABA96D6BB8"
}
],
"unencrypted_suffix": "_unencrypted",
"version": "3.7.3"
}
}
1 change: 1 addition & 0 deletions home-manager/maya/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
../common/borgmatic.nix
../common/media.nix
../common/development.nix
../common/email
../common/desktop_environment
];

Expand Down
1 change: 1 addition & 0 deletions home-manager/yukari/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
imports = [
../common/terminal_environment
../common/borgmatic.nix
../common/email
];

programs.borgmatic.backups."main" = {
Expand Down
5 changes: 4 additions & 1 deletion treefmt.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[formatter.nix]
command = "alejandra"
includes = [ "*.nix" ]
excludes = [ "*/hardware-configuration.nix" ]
excludes = [
"*/hardware-configuration.nix",
"home-manager/common/email/secrets.nix",
]

0 comments on commit 5071654

Please sign in to comment.