aboutsummaryrefslogtreecommitdiff
path: root/modules/workstation/mail/timer.nix
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2019-10-05 22:09:49 +0000
committerKatharina Fey <kookie@spacekookie.de>2019-10-05 22:09:49 +0000
commitc04d9504fa2ae8f447ef05a1e7ddb3b21ed06af9 (patch)
tree4dcadc971cabf2f96f5ef832a5664ae31c052051 /modules/workstation/mail/timer.nix
parent0a6d1447db7d1f52517a4a4c47d4198451fd223e (diff)
Adding workstation module
Diffstat (limited to 'modules/workstation/mail/timer.nix')
-rw-r--r--modules/workstation/mail/timer.nix41
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/workstation/mail/timer.nix b/modules/workstation/mail/timer.nix
new file mode 100644
index 00000000000..468ae263cd0
--- /dev/null
+++ b/modules/workstation/mail/timer.nix
@@ -0,0 +1,41 @@
+{ pkgs, config, ... }:
+
+{
+ environment.systemPackages = with pkgs; [ isync ];
+
+ systemd.services.isync =
+ let
+ maildir = "${config.users.users.spacekookie.home}/office/mail";
+ mbsyncrc = pkgs.writeText "mbsyncrc"
+ (import ../../../ext/mail/mbsyncrc.nix { inherit maildir; });
+ in with pkgs; {
+ serviceConfig.Type = "oneshot";
+ script = ''
+ ${sudo}/bin/sudo -u spacekookie-mail \
+ ${isync}/bin/mbsync -a -V -c ${mbsyncrc}
+ '';
+ postStart = ''
+ ${findutils}/bin/find \
+ "${maildir}" \
+ \! -name .mbsyncstate* \
+ \( \
+ \( \! -user spacekookie -o \! -group spacekookie \) \
+ -exec ${coreutils}/bin/chown spacekookie:spacekookie '{}' \; \
+ , \
+ -type f \! -perm 660 \
+ -exec ${coreutils}/bin/chmod 0660 '{}' \; \
+ , \
+ -type d \! -perm 770 \
+ -exec ${coreutils}/bin/chmod 0770 '{}' \; \
+ \)
+ '';
+ };
+
+ systemd.timers.isync = {
+ timerConfig.Unit = "isync.service";
+ timerConfig.OnCalendar = "*:0/5";
+ timerConfig.Persistent = "true";
+ after = [ "network-online.target" ];
+ wantedBy = [ "timers.target" ];
+ };
+}