2021-06-27 00:29:42 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.programs.himalaya;
|
|
|
|
|
|
|
|
enabledAccounts =
|
|
|
|
lib.filterAttrs (_: a: a.himalaya.enable) (config.accounts.email.accounts);
|
|
|
|
|
|
|
|
tomlFormat = pkgs.formats.toml { };
|
|
|
|
|
|
|
|
himalayaConfig = let
|
|
|
|
toHimalayaConfig = account:
|
|
|
|
{
|
|
|
|
email = account.address;
|
|
|
|
name = account.realName;
|
|
|
|
default = account.primary;
|
|
|
|
|
2022-05-30 21:04:13 +02:00
|
|
|
mailboxes = {
|
|
|
|
inbox = account.folders.inbox;
|
|
|
|
sent = account.folders.sent;
|
|
|
|
draft = account.folders.drafts;
|
|
|
|
# NOTE: himalaya does not support configuring the name of the trash folder
|
|
|
|
};
|
2022-02-21 23:20:44 +01:00
|
|
|
|
2021-06-27 00:29:42 +02:00
|
|
|
# FIXME: does not support disabling TLS altogether
|
|
|
|
# NOTE: does not accept sequence of strings for password commands
|
|
|
|
imap-login = account.userName;
|
|
|
|
imap-passwd-cmd = lib.escapeShellArgs account.passwordCommand;
|
|
|
|
imap-host = account.imap.host;
|
|
|
|
imap-port = account.imap.port;
|
|
|
|
imap-starttls = account.imap.tls.useStartTls;
|
|
|
|
|
|
|
|
smtp-login = account.userName;
|
|
|
|
smtp-passwd-cmd = lib.escapeShellArgs account.passwordCommand;
|
|
|
|
smtp-host = account.smtp.host;
|
|
|
|
smtp-port = account.smtp.port;
|
2022-02-21 22:32:32 +01:00
|
|
|
smtp-starttls = account.smtp.tls.useStartTls;
|
2021-06-27 00:29:42 +02:00
|
|
|
} // (lib.optionalAttrs (account.signature.showSignature == "append") {
|
|
|
|
# FIXME: signature cannot be attached
|
|
|
|
signature = account.signature.text;
|
|
|
|
}) // account.himalaya.settings;
|
|
|
|
in {
|
|
|
|
# NOTE: will not start without this configured, but each account overrides it
|
|
|
|
name = "";
|
|
|
|
} // cfg.settings // (lib.mapAttrs (_: toHimalayaConfig) enabledAccounts);
|
|
|
|
in {
|
|
|
|
meta.maintainers = with lib.hm.maintainers; [ ambroisie ];
|
|
|
|
|
|
|
|
options = with lib; {
|
|
|
|
programs.himalaya = {
|
|
|
|
enable = mkEnableOption "himalaya mail client";
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.himalaya;
|
2021-10-09 11:14:08 +02:00
|
|
|
defaultText = literalExpression "pkgs.himalaya";
|
2021-06-27 00:29:42 +02:00
|
|
|
description = ''
|
|
|
|
Package providing the <command>himalaya</command> mail client.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = tomlFormat.type;
|
|
|
|
default = { };
|
2021-10-09 11:14:08 +02:00
|
|
|
example = lib.literalExpression ''
|
2021-06-27 00:29:42 +02:00
|
|
|
{
|
|
|
|
default-page-size = 50;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Global <command>himalaya</command> configuration values.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
accounts.email.accounts = mkOption {
|
|
|
|
type = with types;
|
|
|
|
attrsOf (submodule {
|
|
|
|
options.himalaya = {
|
|
|
|
enable = mkEnableOption ''
|
|
|
|
the himalaya mail client for this account
|
|
|
|
'';
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = tomlFormat.type;
|
|
|
|
default = { };
|
2021-10-09 11:14:08 +02:00
|
|
|
example = lib.literalExpression ''
|
2021-06-27 00:29:42 +02:00
|
|
|
{
|
|
|
|
default-page-size = 50;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Extra settings to add to this <command>himalaya</command>
|
|
|
|
account configuration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
|
|
|
xdg.configFile."himalaya/config.toml".source =
|
|
|
|
tomlFormat.generate "himalaya-config.toml" himalayaConfig;
|
|
|
|
};
|
|
|
|
}
|