Combine mail setup with calendar and contacts

Move mail into accounts expression set
Add vdirsyncer and initial config to sync to CalDAV and CardDAV

TODO add to emacs
This commit is contained in:
Evie Litherland-Smith 2023-09-02 08:41:07 +01:00
parent df557003e2
commit a615762940
9 changed files with 212 additions and 160 deletions

View file

@ -0,0 +1,112 @@
{ pkgs, hostName, ... }:
''
IMAPAccount protonmail
Host 127.0.0.1
Port 1143
User e.litherlandsmith@proton.me
PassCmd +"${pkgs.pass}/bin/pass show Mail/Proton/${hostName}"
SSLType NONE
AuthMechs LOGIN
IMAPAccount icloud
Host imap.mail.me.com
Port 993
User edwardjls@me.com
PassCmd +"${pkgs.pass}/bin/pass show Mail/iCloud/mbsync"
SSLType IMAPS
IMAPAccount ukaea
Host 127.0.0.1
Port 1144
User evie.litherland-smith@ukaea.uk
PassCmd +"${pkgs.pass}/bin/pass show Mail/Outlook/ukaea"
SSLType None
AuthMechs LOGIN
IMAPStore ProtonRemote
Account protonmail
IMAPStore iCloudRemote
Account icloud
IMAPStore UKAEARemote
Account ukaea
MaildirStore ProtonLocal
Path ~/.mail/Proton/
Inbox ~/.mail/Proton/Inbox/
SubFolders Verbatim
MaildirStore iCloudLocal
Path ~/.mail/iCloud/
Inbox ~/.mail/iCloud/Inbox/
SubFolders Verbatim
MaildirStore UKAEALocal
Path ~/.mail/UKAEA/
Inbox ~/.mail/UKAEA/Inbox/
SubFolders Verbatim
Channel ProtonInbox
Far :ProtonRemote:"INBOX"
Near :ProtonLocal:"Inbox"
Create Near
Expunge Both
SyncState *
Channel ProtonFolders
Far :ProtonRemote:
Near :ProtonLocal:
Patterns * !"All Mail" !"INBOX" !"Inbox"
Create Both
Expunge Both
SyncState *
Channel iCloudInbox
Far :iCloudRemote:"INBOX"
Near :iCloudLocal:"Inbox"
Create Near
Expunge Both
SyncState *
Channel iCloudFolders
Far :iCloudRemote:
Near :iCloudLocal:
Patterns * !"All Mail" !"INBOX" !"Inbox"
Create Both
Expunge Both
SyncState *
Channel UKAEAInbox
Far :UKAEARemote:"INBOX"
Near :UKAEALocal:"Inbox"
Create Near
Expunge Both
SyncState *
Channel UKAEAFolders
Far :UKAEARemote:
Near :UKAEALocal:
Patterns * !"INBOX" !"Inbox"
Create Near
Expunge Both
SyncState *
Group icloud
Channel iCloudInbox
Channel iCloudFolders
Group protonmail
Channel ProtonInbox
Channel ProtonFolders
Group ukaea
Channel UKAEAInbox
Channel UKAEAFolders
Group inbox
Channel iCloudInbox
Channel ProtonInbox
Channel UKAEAInbox
''

View file

@ -0,0 +1,33 @@
{ pkgs, hostName, ... }:
''
defaults
port 587
account protonmail
host 127.0.0.1
from e.litherlandsmith@proton.me
auth login
user e.litherlandsmith@proton.me
passwordeval "${pkgs.pass}/bin/pass show Mail/Proton/${hostName}"
port 1025
tls off
account icloud
host smtp.mail.me.com
from e.litherlandsmith@icloud.com
auth on
user e.litherlandsmith@icloud.com
passwordeval "${pkgs.pass}/bin/pass show Mail/iCloud/mbsync"
port 587
tls on
account ukaea
host 127.0.0.1
from evie.litherland-smith@ukaea.uk
auth login
user evie.litherland-smith@ukaea.uk
passwordeval "${pkgs.pass}/bin/pass show Mail/Outlook/ukaea"
port 1026
tls off
''

View file

@ -0,0 +1,43 @@
{ pkgs, ... }:
''
[general]
# A folder where vdirsyncer can store some metadata about each pair.
status_path = "~/.vdirsyncer/status/"
# CARDDAV
[pair nextcloud_contacts]
a = "nextcloud_contacts_local"
b = "nextcloud_contacts_remote"
collections = ["from a", "from b"]
metadata = ["displayname"]
conflict_resolution = null
[storage nextcloud_contacts_local]
type = "filesystem"
path = "~/.contacts/"
fileext = ".vcf"
[storage nextcloud_contacts_remote]
type = "carddav"
url = "https://cloud.xenia.me.uk/remote.php/dav/addressbooks/users/xenia/contacts-1/"
username = "xenia"
password.fetch = ["shell", "${pkgs.pass}/bin/pass show Calendar/NextCloud/emacs | head -n1"]
# CALDAV
[pair nextcloud_calendar]
a = "nextcloud_calendar_local"
b = "nextcloud_calendar_remote"
collections = ["from a", "from b"]
metadata = ["displayname", "color"]
[storage nextcloud_calendar_local]
type = "singlefile"
path = "~/.calendars/%s.ics"
[storage nextcloud_calendar_remote]
type = "caldav"
url = "https://cloud.xenia.me.uk/remote.php/dav"
username = "xenia"
password.fetch = ["shell", "${pkgs.pass}/bin/pass show Calendar/NextCloud/emacs | head -n1"]
''

20
home/accounts/default.nix Normal file
View file

@ -0,0 +1,20 @@
{ lib, pkgs, hostName, ... }:
{
# accounts.emails.accounts = {}; # TODO
home.packages = with pkgs; [ protonmail-bridge davmail vdirsyncer ];
programs = {
mu.enable = true;
mbsync = {
enable = true;
extraConfig = import ./config/mbsync.nix { inherit pkgs hostName; };
};
msmtp = {
enable = true;
extraConfig = import ./config/msmtp.nix { inherit pkgs hostName; };
};
# vdirsyncer = { enable = true; };
};
xdg.configFile."vdirsyncer/config".text =
import ./config/vdirsyncer.nix { inherit pkgs; };
}

View file

@ -2,12 +2,12 @@
{
imports = [
./accounts/service.nix
./pass/agent.nix
./git/default.nix
./ssh/default.nix
./tui/default.nix
./tmux/default.nix
./mail/service.nix
./hyprland/default.nix
./alacritty/default.nix
./firefox/default.nix

View file

@ -1,7 +1,7 @@
{ pkgs, ... }:
{
imports = [ ../git/default.nix ../mail/default.nix ];
imports = [ ../accounts/default.nix ../git/default.nix ];
programs.emacs.enable = true;
home.packages = with pkgs; [
# Emacs dependencies

View file

@ -1,156 +0,0 @@
{ pkgs, hostName, ... }:
{
# accounts.emails.accounts = {}; # TODO
home.packages = with pkgs; [ protonmail-bridge davmail ];
programs = {
mu.enable = true;
mbsync = {
enable = true;
extraConfig = ''
IMAPAccount protonmail
Host 127.0.0.1
Port 1143
User e.litherlandsmith@proton.me
PassCmd +"${pkgs.pass}/bin/pass show Mail/Proton/${hostName}"
SSLType NONE
AuthMechs LOGIN
IMAPAccount icloud
Host imap.mail.me.com
Port 993
User edwardjls@me.com
PassCmd +"${pkgs.pass}/bin/pass show Mail/iCloud/mbsync"
SSLType IMAPS
IMAPAccount ukaea
Host 127.0.0.1
Port 1144
User evie.litherland-smith@ukaea.uk
PassCmd +"${pkgs.pass}/bin/pass show Mail/Outlook/ukaea"
SSLType None
AuthMechs LOGIN
IMAPStore ProtonRemote
Account protonmail
IMAPStore iCloudRemote
Account icloud
IMAPStore UKAEARemote
Account ukaea
MaildirStore ProtonLocal
Path ~/.mail/Proton/
Inbox ~/.mail/Proton/Inbox/
SubFolders Verbatim
MaildirStore iCloudLocal
Path ~/.mail/iCloud/
Inbox ~/.mail/iCloud/Inbox/
SubFolders Verbatim
MaildirStore UKAEALocal
Path ~/.mail/UKAEA/
Inbox ~/.mail/UKAEA/Inbox/
SubFolders Verbatim
Channel ProtonInbox
Far :ProtonRemote:"INBOX"
Near :ProtonLocal:"Inbox"
Create Near
Expunge Both
SyncState *
Channel ProtonFolders
Far :ProtonRemote:
Near :ProtonLocal:
Patterns * !"All Mail" !"INBOX" !"Inbox"
Create Both
Expunge Both
SyncState *
Channel iCloudInbox
Far :iCloudRemote:"INBOX"
Near :iCloudLocal:"Inbox"
Create Near
Expunge Both
SyncState *
Channel iCloudFolders
Far :iCloudRemote:
Near :iCloudLocal:
Patterns * !"All Mail" !"INBOX" !"Inbox"
Create Both
Expunge Both
SyncState *
Channel UKAEAInbox
Far :UKAEARemote:"INBOX"
Near :UKAEALocal:"Inbox"
Create Near
Expunge Both
SyncState *
Channel UKAEAFolders
Far :UKAEARemote:
Near :UKAEALocal:
Patterns * !"INBOX" !"Inbox"
Create Near
Expunge Both
SyncState *
Group icloud
Channel iCloudInbox
Channel iCloudFolders
Group protonmail
Channel ProtonInbox
Channel ProtonFolders
Group ukaea
Channel UKAEAInbox
Channel UKAEAFolders
Group inbox
Channel iCloudInbox
Channel ProtonInbox
Channel UKAEAInbox
'';
};
msmtp = {
enable = true;
extraConfig = ''
defaults
port 587
account protonmail
host 127.0.0.1
from e.litherlandsmith@proton.me
auth login
user e.litherlandsmith@proton.me
passwordeval "${pkgs.pass}/bin/pass show Mail/Proton/${hostName}"
port 1025
tls off
account icloud
host smtp.mail.me.com
from e.litherlandsmith@icloud.com
auth on
user e.litherlandsmith@icloud.com
passwordeval "${pkgs.pass}/bin/pass show Mail/iCloud/mbsync"
port 587
tls on
account ukaea
host 127.0.0.1
from evie.litherland-smith@ukaea.uk
auth login
user evie.litherland-smith@ukaea.uk
passwordeval "${pkgs.pass}/bin/pass show Mail/Outlook/ukaea"
port 1026
tls off
'';
};
};
}

View file

@ -1,14 +1,14 @@
{ lib, pkgs, user, shell ? "zsh", ... }:
{ pkgs, user, shell ? "zsh", ... }:
let homeDirectory = "/Users/${user}";
in {
imports = [
../../home/shell/${shell}.nix
../../home/accounts/default.nix
../../home/pass/default.nix
../../home/git/default.nix
../../home/ssh/default.nix
../../home/tui/default.nix
../../home/tmux/default.nix
../../home/mail/default.nix
../../home/alacritty/default.nix
../../home/emacs/default.nix
];