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.nix56
1 files changed, 25 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" ];
+  };
 }