summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2019-10-09 17:52:28 +0200
committerAlan Pearce2019-10-09 17:53:01 +0200
commit21bdf17d577d87a01e3caaad6b96b58746b51f90 (patch)
treed768b23b0ff302880f8d71843dd20c333ccf844a
parent7f06dcd355a37f384589c0f01f7c33de8e00bdca (diff)
downloadnixfiles-21bdf17d577d87a01e3caaad6b96b58746b51f90.tar.lz
nixfiles-21bdf17d577d87a01e3caaad6b96b58746b51f90.tar.zst
nixfiles-21bdf17d577d87a01e3caaad6b96b58746b51f90.zip
Unify mail setup
-rw-r--r--system/satoshipad.nix19
-rw-r--r--system/settings/user-interface.nix5
-rw-r--r--user/emacs/.emacs.d/init.el14
-rw-r--r--user/isync/.mbsyncrc37
-rw-r--r--user/msmtp/.msmtprc17
-rw-r--r--user/satoshipad.nix5
-rw-r--r--user/settings/isync.nix5
-rw-r--r--user/settings/mail.nix25
-rw-r--r--user/settings/msmtp.nix5
-rw-r--r--user/settings/satoshipay.nix31
10 files changed, 66 insertions, 97 deletions
diff --git a/system/satoshipad.nix b/system/satoshipad.nix
index 84d2407f..760181e6 100644
--- a/system/satoshipad.nix
+++ b/system/satoshipad.nix
@@ -43,23 +43,4 @@
   virtualisation.docker.autoPrune.dates = "Mon, 13:00";
 
   system.stateVersion = "18.03";
-
-  systemd.user.services.mbsync = {
-    description = "Mailbox synchronisation";
-    path = with pkgs; [ python3Packages.keyring ];
-    serviceConfig = {
-      Type = "oneshot";
-      ExecStart = "${pkgs.isync}/bin/mbsync -Va";
-      # ExecStartPost = "${pkgs.myEmacs}/bin/emacsclient -e (mu4e-update-index)";
-    };
-  };
-
-  systemd.user.timers.mbsync = {
-    description = "Mailbox synchronisation timer";
-    wantedBy = [ "default.target" ];
-    timerConfig = {
-      OnBootSec = "2m";
-      OnUnitActiveSec = "10m";
-    };
-  };
 }
diff --git a/system/settings/user-interface.nix b/system/settings/user-interface.nix
index 08d390ab..c23eec81 100644
--- a/system/settings/user-interface.nix
+++ b/system/settings/user-interface.nix
@@ -21,11 +21,6 @@
     lxrandr
     lxtask
 
-    python3Packages.keyring
-    isync
-    msmtp
-    html2text
-
     weechat
 
     mpv
diff --git a/user/emacs/.emacs.d/init.el b/user/emacs/.emacs.d/init.el
index 5c30ce82..a6ff1f6c 100644
--- a/user/emacs/.emacs.d/init.el
+++ b/user/emacs/.emacs.d/init.el
@@ -812,14 +812,14 @@ _p_rev       _u_pper              _=_: upper/lower       _r_esolve
                                                   (string-equal (system-name) "satoshipad")))
                                   :vars '((user-mail-address . "alan@satoshipay.io")
                                           (mu4e-sent-messages-behavior . delete)
-                                          (mu4e-drafts-folder . "/satoshipay/Drafts")
-                                          (mu4e-sent-folder . "/satoshipay/Sent Mail")
-                                          (mu4e-refile-folder . "/satoshipay/All Mail")
-                                          (mu4e-trash-folder . "/satoshipay/Bin")
+                                          (mu4e-drafts-folder . "/satoshipay/[Gmail]/Drafts")
+                                          (mu4e-sent-folder . "/satoshipay/[Gmail]/Sent Mail")
+                                          (mu4e-refile-folder . "/satoshipay/[Gmail]/All Mail")
+                                          (mu4e-trash-folder . "/satoshipay/[Gmail]/Bin")
                                           (mu4e-maildir-shortcuts . (("/satoshipay/INBOX" . ?i)
-                                                                     ("/satoshipay/All Mail" . ?a)
-                                                                     ("/satoshipay/Sent Mail" . ?s)
-                                                                     ("/satoshipay/Spam" . ?p)))))))))
+                                                                     ("/satoshipay/[Gmail]/All Mail" . ?a)
+                                                                     ("/satoshipay/[Gmail]/Sent Mail" . ?s)
+                                                                     ("/satoshipay/[Gmail]/Spam" . ?p)))))))))
 
 ;;; Take me to my leader
 
diff --git a/user/isync/.mbsyncrc b/user/isync/.mbsyncrc
deleted file mode 100644
index 396bc6a6..00000000
--- a/user/isync/.mbsyncrc
+++ /dev/null
@@ -1,37 +0,0 @@
-# Globals
-Create Both
-Remove Both
-Expunge Both
-CopyArrivalDate yes
-FSync no
-
-## Satoshipay
-# Account
-IMAPAccount satoshipay.io
-Host imap.gmail.com
-User alan@satoshipay.io
-PassCmd "keyring get satoshipay-google-mail alan@satoshipay.io"
-SSLType IMAPS
-SSLVersions TLSv1.2 TLSv1.1
-
-# Remote
-IMAPStore satoshipay.io-remote
-Account satoshipay.io
-
-# Local
-MaildirStore satoshipay.io-local
-Path ~/mail/satoshipay/
-Inbox ~/mail/satoshipay/INBOX
-SubFolders Verbatim
-
-# Job
-Channel satoshipay
-Master :satoshipay.io-remote:
-Slave :satoshipay.io-local:
-Patterns INBOX
-SyncState *
-
-Channel satoshipay-gmail
-Master :satoshipay.io-remote:[Gmail]/
-Slave :satoshipay.io-local:
-Patterns * !INBOX
\ No newline at end of file
diff --git a/user/msmtp/.msmtprc b/user/msmtp/.msmtprc
deleted file mode 100644
index da5c5daf..00000000
--- a/user/msmtp/.msmtprc
+++ /dev/null
@@ -1,17 +0,0 @@
-# Set default values for all following accounts.
-defaults
-auth           on
-tls            on
-tls_trust_file /etc/ssl/certs/ca-certificates.crt
-logfile        ~/.local/log/msmtp.log
-
-account        satoshipay
-host           smtp.gmail.com
-from           alan@satoshipay.io
-user           alan@satoshipay.io
-port           465
-tls_starttls   off
-passwordeval   keyring get satoshipay-google-mail alan@satoshipay.io
-
-# Set a default account
-account default : satoshipay
diff --git a/user/satoshipad.nix b/user/satoshipad.nix
index 3dda7bd1..d5f404c6 100644
--- a/user/satoshipad.nix
+++ b/user/satoshipad.nix
@@ -10,9 +10,8 @@
     ./settings/git.nix
     ./settings/gnupg.nix
     ./settings/i3.nix
-    ./settings/isync.nix
     ./settings/javascript.nix
-    ./settings/msmtp.nix
+    ./settings/mail.nix
     ./settings/nixos.nix
     ./settings/rofi.nix
     ./settings/passwords.nix
@@ -25,6 +24,8 @@
     ./settings/zsh.nix
   ];
 
+  accounts.email.accounts.satoshipay.primary = true;
+
   xsession.windowManager.i3 = {
     config = {
       assigns = {
diff --git a/user/settings/isync.nix b/user/settings/isync.nix
deleted file mode 100644
index b96db87d..00000000
--- a/user/settings/isync.nix
+++ /dev/null
@@ -1,5 +0,0 @@
-{ config, pkgs, ... }:
-
-{
-  home.file.".mbsyncrc".source = ../isync/.mbsyncrc;
-}
diff --git a/user/settings/mail.nix b/user/settings/mail.nix
new file mode 100644
index 00000000..3ce9e548
--- /dev/null
+++ b/user/settings/mail.nix
@@ -0,0 +1,25 @@
+{ config, pkgs, ... }:
+
+{
+  home.packages = [
+    pkgs.html2text
+  ];
+  accounts.email = {
+    maildirBasePath = "mail";
+  };
+  programs.mbsync = {
+    enable = true;
+    extraConfig = ''
+      CopyArrivalDate yes
+      FSync no
+    '';
+  };
+  services.mbsync = {
+    enable = true;
+    frequency = "*:6/15";
+    postExec = "${config.programs.emacs.finalPackage}/bin/emacsclient -e (mu4e-update-index)";
+  };
+  programs.msmtp = {
+    enable = true;
+  };
+}
diff --git a/user/settings/msmtp.nix b/user/settings/msmtp.nix
deleted file mode 100644
index 45c2f460..00000000
--- a/user/settings/msmtp.nix
+++ /dev/null
@@ -1,5 +0,0 @@
-{ config, pkgs, ... }:
-
-{
-  home.file.".msmtprc".source = ../msmtp/.msmtprc;
-}
diff --git a/user/settings/satoshipay.nix b/user/settings/satoshipay.nix
index 6516bd59..822f6b6f 100644
--- a/user/settings/satoshipay.nix
+++ b/user/settings/satoshipay.nix
@@ -49,6 +49,37 @@ in
     }
   ];
 
+  accounts.email.accounts.satoshipay = let
+    address = "alan@satoshipay.io";
+  in
+  {
+    inherit address;
+    realName = "Alan Pearce";
+    flavor = "gmail.com";
+    passwordCommand = "${pkgs.python3Packages.keyring}/bin/keyring get satoshipay-google-mail ${address}";
+    folders = {
+      inbox = "INBOX";
+      drafts = "[Gmail]/Drafts";
+      sent = "[Gmail]/Sent Mail";
+      trash = "[Gmail]/Bin";
+    };
+    imap = {
+      tls.enable = true;
+    };
+    smtp = {
+      tls.enable = true;
+    };
+    mbsync = {
+      enable = true;
+      create = "maildir";
+      remove = "maildir";
+      expunge = "both";
+    };
+    msmtp = {
+      enable = true;
+    };
+  };
+
   home.file.".npmrc".text = ''
     @satoshipay:registry=https://registry.npmjs.org/
   '';