diff options
author | aszlig <aszlig@redmoonstudios.org> | 2016-09-26 21:18:06 +0200 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2016-09-26 21:18:06 +0200 |
commit | 2af70511974a79814e88c35d0172be5d502ec0c3 (patch) | |
tree | 4529b80e49101bffa808ce53ad4aacc08b71f792 /nixos/modules/services/mail | |
parent | 603b73f1e13399730648374d78d63d715d6bb617 (diff) | |
download | nixlib-2af70511974a79814e88c35d0172be5d502ec0c3.tar nixlib-2af70511974a79814e88c35d0172be5d502ec0c3.tar.gz nixlib-2af70511974a79814e88c35d0172be5d502ec0c3.tar.bz2 nixlib-2af70511974a79814e88c35d0172be5d502ec0c3.tar.lz nixlib-2af70511974a79814e88c35d0172be5d502ec0c3.tar.xz nixlib-2af70511974a79814e88c35d0172be5d502ec0c3.tar.zst nixlib-2af70511974a79814e88c35d0172be5d502ec0c3.zip |
nixos/offlineimap: Move to services/mail
The services/networking directory is already quite polluted and the first point where I was looking for the offlineimap module was in services/mail and didn't find it there. Offlineimap already has IMAP in its name and clearly belongs to the "mail" category so let's move it there. Tested by evaluating a configuration with services.offlineimap enabled. Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @DamienCassou
Diffstat (limited to 'nixos/modules/services/mail')
-rw-r--r-- | nixos/modules/services/mail/offlineimap.nix | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/nixos/modules/services/mail/offlineimap.nix b/nixos/modules/services/mail/offlineimap.nix new file mode 100644 index 000000000000..85ece020905b --- /dev/null +++ b/nixos/modules/services/mail/offlineimap.nix @@ -0,0 +1,73 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.offlineimap; +in { + + options.services.offlineimap = { + enable = mkEnableOption "Offlineimap, a software to dispose your mailbox(es) as a local Maildir(s)."; + + install = mkOption { + type = types.bool; + default = false; + example = true; + description = '' + Whether to install a user service for Offlineimap. Once + the service is started, emails will be fetched automatically. + + The service must be manually started for each user with + "systemctl --user start offlineimap" or globally through + <varname>services.offlineimap.enable</varname>. + ''; + }; + + package = mkOption { + type = types.package; + default = pkgs.offlineimap; + defaultText = "pkgs.offlineimap"; + description = "Offlineimap derivation to use."; + }; + + path = mkOption { + type = types.listOf types.path; + default = []; + example = literalExample "[ pkgs.pass pkgs.bash pkgs.notmuch ]"; + description = "List of derivations to put in Offlineimap's path."; + }; + + onCalendar = mkOption { + type = types.str; + default = "*:0/3"; # every 3 minutes + description = "How often is offlineimap started. Default is '*:0/3' meaning every 3 minutes. See systemd.time(7) for more information about the format."; + }; + + timeoutStartSec = mkOption { + type = types.str; + default = "120sec"; # Kill if still alive after 2 minutes + description = "How long waiting for offlineimap before killing it. Default is '120sec' meaning every 2 minutes. See systemd.time(7) for more information about the format."; + }; + }; + config = mkIf (cfg.enable || cfg.install) { + systemd.user.services.offlineimap = { + description = "Offlineimap: a software to dispose your mailbox(es) as a local Maildir(s)"; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${cfg.package}/bin/offlineimap -u syslog -o -1"; + TimeoutStartSec = cfg.timeoutStartSec; + }; + path = cfg.path; + }; + environment.systemPackages = [ cfg.package ]; + systemd.user.timers.offlineimap = { + description = "offlineimap timer"; + timerConfig = { + Unit = "offlineimap.service"; + OnCalendar = cfg.onCalendar; + # start immediately after computer is started: + Persistent = "true"; + }; + } // optionalAttrs cfg.enable { wantedBy = [ "default.target" ]; }; + }; +} |