about summary refs log tree commit diff
path: root/modules/workstation/mail/isync/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/workstation/mail/isync/default.nix')
-rw-r--r--modules/workstation/mail/isync/default.nix36
1 files changed, 36 insertions, 0 deletions
diff --git a/modules/workstation/mail/isync/default.nix b/modules/workstation/mail/isync/default.nix
new file mode 100644
index 000000000000..66343a0c3625
--- /dev/null
+++ b/modules/workstation/mail/isync/default.nix
@@ -0,0 +1,36 @@
+{ pkgs, options, ... }:
+
+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
+            '';
+          };
+        };
+
+        systemd.user.timers.isync = {
+          timerConfig = {
+            Unit = "isync.service";
+            OnCalendar = "*:0/5";
+            Persistent = "true";
+          };
+          wantedBy = [ "default.target" ];
+        };
+      };
+}