1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-15 17:51:01 +00:00

Merge pull request #81 from periklis/service-offlineimap

Init offlineimap service
This commit is contained in:
Daiderd Jordan 2018-06-06 20:39:19 +02:00 committed by GitHub
commit 6f970ca1b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 108 additions and 0 deletions

View file

@ -50,6 +50,7 @@ let
./modules/services/emacs.nix
./modules/services/khd
./modules/services/kwm
./modules/services/mail/offlineimap.nix
./modules/services/mopidy.nix
./modules/services/nix-daemon.nix
./modules/services/nix-gc

View file

@ -0,0 +1,63 @@
{ 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).";
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.";
};
startInterval = mkOption {
type = types.nullOr types.int;
default = 300;
example = literalExample "300";
description = "Optional key to start offlineimap services each N seconds";
};
runQuick = mkOption {
type = types.bool;
default = false;
description = ''
Run only quick synchronizations.
Ignore any flag updates on IMAP servers. If a flag on the remote IMAP changes, and we have the message locally, it will be left untouched in a quick run.
'';
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = "Additional text to be appended to <filename>offlineimaprc</filename>.";
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
environment.etc."offlineimaprc".text = cfg.extraConfig;
launchd.user.agents.offlineimap = {
path = [ cfg.package ];
command = "offlineimap";
serviceConfig.KeepAlive = false;
serviceConfig.RunAtLoad = true;
serviceConfig.ProgramArguments = [ "-c" "/etc/offlineimaprc" ] ++ optional (cfg.runQuick) "-q";
serviceConfig.StartInterval = cfg.startInterval;
serviceConfig.StandardErrorPath = "/var/log/offlineimap.log";
serviceConfig.StandardOutPath = "/var/log/offlineimap.log";
};
};
}

View file

@ -101,6 +101,7 @@ let
tests.services-activate-system = makeTest ./tests/services-activate-system.nix;
tests.services-buildkite-agent = makeTest ./tests/services-buildkite-agent.nix;
tests.services-ofborg = makeTest ./tests/services-ofborg.nix;
tests.services-offlineimap = makeTest ./tests/services-offlineimap.nix;
tests.services-skhd = makeTest ./tests/services-skhd.nix;
tests.system-defaults-write = makeTest ./tests/system-defaults-write.nix;
tests.system-keyboard-mapping = makeTest ./tests/system-keyboard-mapping.nix;

View file

@ -0,0 +1,43 @@
{ config, lib, pkgs, ... }:
with lib;
let
offlineimap = pkgs.runCommand "offlineimap-0.0.0" {} "mkdir -p $out";
in
{
services.offlineimap.enable = true;
services.offlineimap.package = offlineimap;
services.offlineimap.runQuick = true;
services.offlineimap.extraConfig = ''
[general]
accounts = test
ui = quiet
[Account test]
localrepository = testLocal
remoterepository = testRemote
autorefresh = 2
maxage = 2017-07-01
[Repository testLocal]
type = GmailMaildir
[Repository testRemote]
type = Gmail
ssl = yes
starttls = no
expunge = yes
'';
test = ''
echo >&2 "checking offlineimap service in ~/Library/LaunchAgents"
grep "org.nixos.offlineimap" ${config.out}/user/Library/LaunchAgents/org.nixos.offlineimap.plist
grep "exec\ offlineimap" ${config.out}/user/Library/LaunchAgents/org.nixos.offlineimap.plist
grep "\-q" ${config.out}/user/Library/LaunchAgents/org.nixos.offlineimap.plist
echo >&2 "checking config in /etc/offlineimaprc"
grep "accounts\ \=\ test" ${config.out}/etc/offlineimaprc
'';
}