all repos — nixfiles @ 21bdf17d577d87a01e3caaad6b96b58746b51f90

System and user configuration, managed by nix and home-manager

Unify mail setup
Alan Pearce alan@alanpearce.eu
Wed, 09 Oct 2019 17:52:28 +0200
commit

21bdf17d577d87a01e3caaad6b96b58746b51f90

parent

7f06dcd355a37f384589c0f01f7c33de8e00bdca

M system/satoshipad.nixsystem/satoshipad.nix
@@ -43,23 +43,4 @@ system.autoUpgrade.dates = "13:24";   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";
-    };
-  };
 }
M system/settings/user-interface.nixsystem/settings/user-interface.nix
@@ -21,11 +21,6 @@ lxappearance     lxrandr
     lxtask
 
-    python3Packages.keyring
-    isync
-    msmtp
-    html2text
-
     weechat
 
     mpv
M user/emacs/.emacs.d/init.eluser/emacs/.emacs.d/init.el
@@ -812,14 +812,14 @@ msg :to ".*@satoshipay.io")                                                   (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
 
D user/isync/.mbsyncrc
@@ -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
D user/msmtp/.msmtprc
@@ -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
M user/satoshipad.nixuser/satoshipad.nix
@@ -10,9 +10,8 @@ ./settings/emacs.nix     ./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
@@ -24,6 +23,8 @@ ./settings/user-interface.nix     ./settings/xresources.nix
     ./settings/zsh.nix
   ];
+
+  accounts.email.accounts.satoshipay.primary = true;
 
   xsession.windowManager.i3 = {
     config = {
D user/settings/isync.nix
@@ -1,5 +0,0 @@-{ config, pkgs, ... }:
-
-{
-  home.file.".mbsyncrc".source = ../isync/.mbsyncrc;
-}
A 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;
+  };
+}
D user/settings/msmtp.nix
@@ -1,5 +0,0 @@-{ config, pkgs, ... }:
-
-{
-  home.file.".msmtprc".source = ../msmtp/.msmtprc;
-}
M user/settings/satoshipay.nixuser/settings/satoshipay.nix
@@ -49,6 +49,37 @@ contents = spGitConfig;     }
   ];
 
+  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/
   '';