2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
72 lines
2.5 KiB
Nix
72 lines
2.5 KiB
Nix
{ 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;
|
|
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 = literalExpression "pkgs.offlineimap";
|
|
description = lib.mdDoc "Offlineimap derivation to use.";
|
|
};
|
|
|
|
path = mkOption {
|
|
type = types.listOf types.path;
|
|
default = [];
|
|
example = literalExpression "[ pkgs.pass pkgs.bash pkgs.notmuch ]";
|
|
description = lib.mdDoc "List of derivations to put in Offlineimap's path.";
|
|
};
|
|
|
|
onCalendar = mkOption {
|
|
type = types.str;
|
|
default = "*:0/3"; # every 3 minutes
|
|
description = lib.mdDoc "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 = lib.mdDoc "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" ]; };
|
|
};
|
|
}
|