diff options
author | Mx Kookie <kookie@spacekookie.de> | 2020-12-23 16:41:20 +0100 |
---|---|---|
committer | Mx Kookie <kookie@spacekookie.de> | 2020-12-23 16:41:20 +0100 |
commit | 606c9d9d1bc41b9ed3b188758109bd44450c90da (patch) | |
tree | 5a02f5e376eeb46b86deb5df0f8d702464297359 /infra/libkookie/modules/workstation/mail/core/isync.nix | |
parent | 93d18a00d9d6ec81ea3f0e1790c80a7ffe879585 (diff) |
libkookie: implement mail module handling via external configuration
Diffstat (limited to 'infra/libkookie/modules/workstation/mail/core/isync.nix')
-rw-r--r-- | infra/libkookie/modules/workstation/mail/core/isync.nix | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/infra/libkookie/modules/workstation/mail/core/isync.nix b/infra/libkookie/modules/workstation/mail/core/isync.nix new file mode 100644 index 000000000000..a736925058a1 --- /dev/null +++ b/infra/libkookie/modules/workstation/mail/core/isync.nix @@ -0,0 +1,32 @@ +{ config, pkgs, ... }: + +let cfg = config.libkookie.workstation.mail; +in +with pkgs; +{ + serviceConfig.Type = "oneshot"; + + script = let + cfgPath = (cfg.configPath + "/mbsyncrc.nix"); + mbsyncBody = (import cfgPath cfg.mailArchive); + mbsyncrc = (writeText "mbsyncrc" mbsyncBody); + in + '' + ${sudo}/bin/sudo -u mail-user ${isync}/bin/mbsync -a -V -c ${mbsyncrc} + ''; + + # This script loops through the mail archive and changes file + # permissions and ownership to allow the main user to access them. + # It then also runs `notmuch new` to update applications. + # + # Yes this script could use a single `find` invocation, but + # personally I've found that to be unclear, and this script running + # in the background means that speed is not of much concearn. + postStart = '' + ${findutils}/bin/find ${cfg.mailArchive} ! -name .mbsyncstate* | xargs chgrp ${cfg.access.group} + ${findutils}/bin/find ${cfg.mailArchive} -type f | xargs chmod 660 + ${findutils}/bin/find ${cfg.mailArchive} -type d | xargs chmod 770 + + ${sudo}/bin/sudo -u ${cfg.access.user} ${notmuch}/bin/notmuch new + ''; +} |