aboutsummaryrefslogtreecommitdiff
path: root/modules/workstation/mail
diff options
context:
space:
mode:
Diffstat (limited to 'modules/workstation/mail')
-rw-r--r--modules/workstation/mail/default.nix9
-rw-r--r--modules/workstation/mail/pkgs.nix16
-rw-r--r--modules/workstation/mail/timer.nix41
3 files changed, 66 insertions, 0 deletions
diff --git a/modules/workstation/mail/default.nix b/modules/workstation/mail/default.nix
new file mode 100644
index 00000000000..eda0ecf609c
--- /dev/null
+++ b/modules/workstation/mail/default.nix
@@ -0,0 +1,9 @@
+{ pkgs, ... }:
+
+{
+ home-manager.users.spacekookie = { ... }: {
+ imports = [ ./pkgs.nix ];
+ };
+
+ imports = [ ./timer.nix ];
+}
diff --git a/modules/workstation/mail/pkgs.nix b/modules/workstation/mail/pkgs.nix
new file mode 100644
index 00000000000..380e1b530a6
--- /dev/null
+++ b/modules/workstation/mail/pkgs.nix
@@ -0,0 +1,16 @@
+/* USERSPACE MAIL CONFIGURATION
+ *
+ * This module depends on the `ext` hook in the repo
+ * root, because it includes private config files
+ * that contain sensitive information.
+ */
+
+{ pkgs, ... }:
+
+{
+ home.packages = with pkgs; [ neomutt notmuch ];
+# imports = [
+# ../../../ext/mail/neomutt.nix
+# ../../../ext/mail/notmuch.nix
+# ];
+}
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" ];
+ };
+}