about summary refs log tree commit diff
path: root/modules/workstation/mail/isync
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-02-10 19:59:18 +0000
committerAlyssa Ross <hi@alyssa.is>2019-02-10 19:59:18 +0000
commite0a178df252d6801108699fa07cd1ea494ebc12d (patch)
tree13217ea9caf3b75a9ff81351ee747d291a1a784a /modules/workstation/mail/isync
parent2349ca0a596f73209c7491769879c065db513ca6 (diff)
downloadnixlib-e0a178df252d6801108699fa07cd1ea494ebc12d.tar
nixlib-e0a178df252d6801108699fa07cd1ea494ebc12d.tar.gz
nixlib-e0a178df252d6801108699fa07cd1ea494ebc12d.tar.bz2
nixlib-e0a178df252d6801108699fa07cd1ea494ebc12d.tar.lz
nixlib-e0a178df252d6801108699fa07cd1ea494ebc12d.tar.xz
nixlib-e0a178df252d6801108699fa07cd1ea494ebc12d.tar.zst
nixlib-e0a178df252d6801108699fa07cd1ea494ebc12d.zip
config: give up on this experiment
This ended up being way more trouble than it was worth, and the approach
just flat out didn't work for stuff like OpenSSH.
Diffstat (limited to 'modules/workstation/mail/isync')
-rw-r--r--modules/workstation/mail/isync/default.nix56
-rw-r--r--modules/workstation/mail/isync/mbsyncrc.nix26
2 files changed, 51 insertions, 31 deletions
diff --git a/modules/workstation/mail/isync/default.nix b/modules/workstation/mail/isync/default.nix
index 66343a0c3625..1ec41d8e13c2 100644
--- a/modules/workstation/mail/isync/default.nix
+++ b/modules/workstation/mail/isync/default.nix
@@ -1,36 +1,30 @@
-{ pkgs, options, ... }:
+{ pkgs, config, ... }:
 
-let
-  inherit (pkgs.pkgsConfigured) isync;
 
-in {
-  config =
-    if options.environment ? "darwinConfig" then
-      {
-        launchd.user.agents.isync = {
-          serviceConfig.ProgramArguments = [ "${isync}/bin/mbsync" "Periodic" ];
-          serviceConfig.StartInterval = 300;
-          serviceConfig.RunAtLoad = true;
-        };
-      }
-    else
-      {
-        systemd.user.services.isync = {
-          serviceConfig = {
-            Type = "oneshot";
-            ExecStart = ''
-              ${isync}/bin/mbsync Periodic
-            '';
-          };
-        };
+{
+  environment.systemPackages = with pkgs; [ isync ];
 
-        systemd.user.timers.isync = {
-          timerConfig = {
-            Unit = "isync.service";
-            OnCalendar = "*:0/5";
-            Persistent = "true";
-          };
-          wantedBy = [ "default.target" ];
-        };
+  systemd.services.isync = 
+    let
+      mbsyncrc = pkgs.writeText "mbsyncrc" (import ./mbsyncrc.nix {
+        maildir = "${config.users.users.qyliss.home}/mail";
+      });
+    in {
+      serviceConfig = {
+        Type = "oneshot";
+        User = "qyliss-mail";
+        ExecStart = ''
+          ${pkgs.isync}/bin/mbsync -a -c ${mbsyncrc}
+        '';
       };
+    };
+
+  systemd.timers.isync = {
+    timerConfig = {
+      Unit = "isync.service";
+      OnCalendar = "*:0/5";
+      Persistent = "true";
+    };
+    wantedBy = [ "multi-user.target" ];
+  };
 }
diff --git a/modules/workstation/mail/isync/mbsyncrc.nix b/modules/workstation/mail/isync/mbsyncrc.nix
new file mode 100644
index 000000000000..3a093e35efb5
--- /dev/null
+++ b/modules/workstation/mail/isync/mbsyncrc.nix
@@ -0,0 +1,26 @@
+{ maildir }:
+
+''
+Create Both
+
+MaildirStore local
+  Path ${maildir}/
+  Inbox ${maildir}/INBOX
+  Subfolders Verbatim
+
+IMAPAccount fastmail
+  Host imap.fastmail.com
+  User alyssa@fastmail.com
+  PassCmd "cat ~/imappass"
+  SSLType IMAPS
+  SSLVersions TLSv1.2
+
+IMAPStore fastmail-remote
+  Account fastmail
+
+Channel fastmail
+  Master :fastmail-remote:
+  Slave :local:
+  Patterns *
+  SyncState *
+''