mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-01 06:31:04 +01:00
himalaya: update for version 1
This commit is contained in:
commit
8c0671c513
2 changed files with 99 additions and 119 deletions
|
|
@ -1,12 +1,14 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
# aliases
|
# aliases
|
||||||
inherit (config.programs) himalaya;
|
inherit (config.programs) himalaya;
|
||||||
tomlFormat = pkgs.formats.toml { };
|
tomlFormat = pkgs.formats.toml { };
|
||||||
|
|
||||||
# attrs util that removes entries containing a null value
|
# attrs util that removes entries containing a null value
|
||||||
compactAttrs = lib.filterAttrs (_: val: !isNull val);
|
compactAttrs = filterAttrs (_: val: !isNull val);
|
||||||
|
|
||||||
# needed for notmuch config, because the DB is here, and not in each
|
# needed for notmuch config, because the DB is here, and not in each
|
||||||
# account's dir
|
# account's dir
|
||||||
|
|
@ -35,7 +37,7 @@ let
|
||||||
email = account.address;
|
email = account.address;
|
||||||
display-name = account.realName;
|
display-name = account.realName;
|
||||||
default = account.primary;
|
default = account.primary;
|
||||||
folder.alias = {
|
folder.aliases = {
|
||||||
inbox = account.folders.inbox;
|
inbox = account.folders.inbox;
|
||||||
sent = account.folders.sent;
|
sent = account.folders.sent;
|
||||||
drafts = account.folders.drafts;
|
drafts = account.folders.drafts;
|
||||||
|
|
@ -44,48 +46,53 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
signatureConfig =
|
signatureConfig =
|
||||||
lib.optionalAttrs (account.signature.showSignature == "append") {
|
optionalAttrs (account.signature.showSignature == "append") {
|
||||||
# TODO: signature cannot be attached yet
|
# TODO: signature cannot be attached yet
|
||||||
# https://todo.sr.ht/~soywod/pimalaya/27
|
# https://github.com/pimalaya/himalaya/issues/534
|
||||||
signature = account.signature.text;
|
signature = account.signature.text;
|
||||||
signature-delim = account.signature.delimiter;
|
signature-delim = account.signature.delimiter;
|
||||||
};
|
};
|
||||||
|
|
||||||
imapConfig = lib.optionalAttrs imapEnabled (compactAttrs {
|
imapConfig = optionalAttrs imapEnabled (compactAttrs {
|
||||||
backend = "imap";
|
backend.type = "imap";
|
||||||
imap.host = account.imap.host;
|
backend.host = account.imap.host;
|
||||||
imap.port = account.imap.port;
|
backend.port = account.imap.port;
|
||||||
imap.encryption = mkEncryptionConfig account.imap.tls;
|
backend.encryption.type = mkEncryptionConfig account.imap.tls;
|
||||||
imap.login = account.userName;
|
backend.login = account.userName;
|
||||||
imap.passwd.cmd = builtins.concatStringsSep " " account.passwordCommand;
|
backend.auth.type = "password";
|
||||||
|
backend.auth.cmd =
|
||||||
|
builtins.concatStringsSep " " account.passwordCommand;
|
||||||
});
|
});
|
||||||
|
|
||||||
maildirConfig = lib.optionalAttrs maildirEnabled (compactAttrs {
|
maildirConfig = optionalAttrs maildirEnabled (compactAttrs {
|
||||||
backend = "maildir";
|
backend.type = "maildir";
|
||||||
maildir.root-dir = account.maildir.absPath;
|
backend.root-dir = account.maildir.absPath;
|
||||||
});
|
});
|
||||||
|
|
||||||
notmuchConfig = lib.optionalAttrs notmuchEnabled (compactAttrs {
|
notmuchConfig = optionalAttrs notmuchEnabled (compactAttrs {
|
||||||
backend = "notmuch";
|
backend.type = "notmuch";
|
||||||
notmuch.database-path = maildirBasePath;
|
backend.db-path = maildirBasePath;
|
||||||
});
|
});
|
||||||
|
|
||||||
smtpConfig = lib.optionalAttrs (!isNull account.smtp) (compactAttrs {
|
smtpConfig = optionalAttrs (!isNull account.smtp) (compactAttrs {
|
||||||
message.send.backend = "smtp";
|
message.send.backend.type = "smtp";
|
||||||
smtp.host = account.smtp.host;
|
message.send.backend.host = account.smtp.host;
|
||||||
smtp.port = account.smtp.port;
|
message.send.backend.port = account.smtp.port;
|
||||||
smtp.encryption = mkEncryptionConfig account.smtp.tls;
|
message.send.backend.encryption.type =
|
||||||
smtp.login = account.userName;
|
mkEncryptionConfig account.smtp.tls;
|
||||||
smtp.passwd.cmd = builtins.concatStringsSep " " account.passwordCommand;
|
message.send.backend.login = account.userName;
|
||||||
|
message.send.backend.auth.type = "password";
|
||||||
|
message.send.backend.auth.cmd =
|
||||||
|
builtins.concatStringsSep " " account.passwordCommand;
|
||||||
});
|
});
|
||||||
|
|
||||||
sendmailConfig =
|
sendmailConfig =
|
||||||
lib.optionalAttrs (isNull account.smtp && !isNull account.msmtp) {
|
optionalAttrs (isNull account.smtp && !isNull account.msmtp) {
|
||||||
sender = "sendmail";
|
message.send.backend.type = "sendmail";
|
||||||
sendmail.cmd = "${pkgs.msmtp}/bin/msmtp";
|
message.send.backend.cmd = getExe pkgs.msmtp;
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.attrsets.mergeAttrsList [
|
config = attrsets.mergeAttrsList [
|
||||||
globalConfig
|
globalConfig
|
||||||
signatureConfig
|
signatureConfig
|
||||||
imapConfig
|
imapConfig
|
||||||
|
|
@ -95,65 +102,49 @@ let
|
||||||
sendmailConfig
|
sendmailConfig
|
||||||
];
|
];
|
||||||
|
|
||||||
in lib.recursiveUpdate config account.himalaya.settings;
|
in recursiveUpdate config account.himalaya.settings;
|
||||||
|
|
||||||
in {
|
in {
|
||||||
meta.maintainers = with lib.hm.maintainers; [ soywod toastal ];
|
meta.maintainers = with hm.maintainers; [ soywod toastal ];
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
(mkRemovedOptionModule [ "services" "himalaya-watch" "enable" ] ''
|
||||||
|
services.himalaya-watch has been removed.
|
||||||
|
|
||||||
|
The watch feature moved away from Himalaya scope, and resides
|
||||||
|
now in its own project called Mirador. Once the v1 released, the
|
||||||
|
service will land back in nixpkgs and home-manager.
|
||||||
|
|
||||||
|
See <https://github.com/pimalaya/mirador>.
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
programs.himalaya = {
|
programs.himalaya = {
|
||||||
enable = lib.mkEnableOption "the email client Himalaya CLI";
|
enable = mkEnableOption "the email client Himalaya CLI";
|
||||||
package = lib.mkPackageOption pkgs "himalaya" { };
|
package = mkPackageOption pkgs "himalaya" { };
|
||||||
settings = lib.mkOption {
|
settings = mkOption {
|
||||||
type = lib.types.submodule { freeformType = tomlFormat.type; };
|
type = types.submodule { freeformType = tomlFormat.type; };
|
||||||
default = { };
|
default = { };
|
||||||
description = ''
|
description = ''
|
||||||
Himalaya CLI global configuration.
|
Himalaya CLI global configuration.
|
||||||
See <https://pimalaya.org/himalaya/cli/latest/configuration/index.html#global-configuration> for supported values.
|
See <https://github.com/pimalaya/himalaya/blob/master/config.sample.toml> for supported values.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.himalaya-watch = {
|
accounts.email.accounts = mkOption {
|
||||||
enable = lib.mkEnableOption
|
type = types.attrsOf (types.submodule {
|
||||||
"the email client Himalaya CLI envelopes watcher service";
|
|
||||||
|
|
||||||
environment = lib.mkOption {
|
|
||||||
type = with lib.types; attrsOf str;
|
|
||||||
default = { };
|
|
||||||
example = lib.literalExpression ''
|
|
||||||
{
|
|
||||||
"PASSWORD_STORE_DIR" = "~/.password-store";
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
description = ''
|
|
||||||
Extra environment variables to be exported in the service.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
settings.account = lib.mkOption {
|
|
||||||
type = with lib.types; nullOr str;
|
|
||||||
default = null;
|
|
||||||
example = "personal";
|
|
||||||
description = ''
|
|
||||||
Name of the account the watcher should be started for.
|
|
||||||
If no account is given, the default one is used.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
accounts.email.accounts = lib.mkOption {
|
|
||||||
type = lib.types.attrsOf (lib.types.submodule {
|
|
||||||
options.himalaya = {
|
options.himalaya = {
|
||||||
enable = lib.mkEnableOption
|
enable = mkEnableOption
|
||||||
"the email client Himalaya CLI for this email account";
|
"the email client Himalaya CLI for this email account";
|
||||||
|
|
||||||
settings = lib.mkOption {
|
settings = mkOption {
|
||||||
type = lib.types.submodule { freeformType = tomlFormat.type; };
|
type = types.submodule { freeformType = tomlFormat.type; };
|
||||||
default = { };
|
default = { };
|
||||||
description = ''
|
description = ''
|
||||||
Himalaya CLI configuration for this email account.
|
Himalaya CLI configuration for this email account.
|
||||||
See <https://pimalaya.org/himalaya/cli/latest/configuration/index.html#account-configuration> for supported values.
|
See <https://github.com/pimalaya/himalaya/blob/master/config.sample.toml> for supported values.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -161,40 +152,28 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf himalaya.enable {
|
config = mkIf himalaya.enable {
|
||||||
home.packages = [ himalaya.package ];
|
home.packages = [ himalaya.package ];
|
||||||
|
|
||||||
xdg.configFile."himalaya/config.toml".source = let
|
xdg = {
|
||||||
enabledAccounts = lib.filterAttrs (_: account: account.himalaya.enable)
|
configFile."himalaya/config.toml".source = let
|
||||||
config.accounts.email.accounts;
|
enabledAccounts = filterAttrs (_: account: account.himalaya.enable)
|
||||||
accountsConfig = lib.mapAttrs mkAccountConfig enabledAccounts;
|
config.accounts.email.accounts;
|
||||||
globalConfig = compactAttrs himalaya.settings;
|
accountsConfig = mapAttrs mkAccountConfig enabledAccounts;
|
||||||
allConfig = globalConfig // { accounts = accountsConfig; };
|
globalConfig = compactAttrs himalaya.settings;
|
||||||
in tomlFormat.generate "himalaya-config.toml" allConfig;
|
allConfig = globalConfig // { accounts = accountsConfig; };
|
||||||
systemd.user.services = let
|
in tomlFormat.generate "himalaya.config.toml" allConfig;
|
||||||
inherit (config.services.himalaya-watch) enable environment settings;
|
|
||||||
optionalArg = key:
|
desktopEntries.himalaya = mkIf pkgs.stdenv.hostPlatform.isLinux {
|
||||||
if (key ? settings && !isNull settings."${key}") then
|
type = "Application";
|
||||||
[ "--${key} ${settings."${key}"}" ]
|
name = "himalaya";
|
||||||
else
|
genericName = "Email Client";
|
||||||
[ ];
|
comment = "CLI to manage emails";
|
||||||
in {
|
terminal = true;
|
||||||
himalaya-watch = lib.mkIf enable {
|
exec = "himalaya %u";
|
||||||
Unit = {
|
categories = [ "Network" ];
|
||||||
Description = "Email client Himalaya CLI envelopes watcher service";
|
mimeType = [ "x-scheme-handler/mailto" "message/rfc822" ];
|
||||||
After = [ "network.target" ];
|
settings = { Keywords = "email"; };
|
||||||
};
|
|
||||||
Install = { WantedBy = [ "default.target" ]; };
|
|
||||||
Service = {
|
|
||||||
ExecStart = lib.concatStringsSep " "
|
|
||||||
([ "${himalaya.package}/bin/himalaya" "envelopes" "watch" ]
|
|
||||||
++ optionalArg "account");
|
|
||||||
ExecSearchPath = "/bin";
|
|
||||||
Environment =
|
|
||||||
lib.mapAttrsToList (key: val: "${key}=${val}") environment;
|
|
||||||
Restart = "always";
|
|
||||||
RestartSec = 10;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,33 @@
|
||||||
[accounts."hm@example.com"]
|
[accounts."hm@example.com"]
|
||||||
backend = "imap"
|
|
||||||
default = true
|
default = true
|
||||||
display-name = "H. M. Test"
|
display-name = "H. M. Test"
|
||||||
email = "hm@example.com"
|
email = "hm@example.com"
|
||||||
|
[accounts."hm@example.com".backend]
|
||||||
|
host = "imap.example.com"
|
||||||
|
login = "home.manager"
|
||||||
|
port = 993
|
||||||
|
type = "imap"
|
||||||
|
[accounts."hm@example.com".backend.auth]
|
||||||
|
cmd = "password-command"
|
||||||
|
type = "password"
|
||||||
|
|
||||||
[accounts."hm@example.com".folder.alias]
|
[accounts."hm@example.com".backend.encryption]
|
||||||
|
type = "tls"
|
||||||
|
|
||||||
|
[accounts."hm@example.com".folder.aliases]
|
||||||
drafts = "Drafts"
|
drafts = "Drafts"
|
||||||
inbox = "Inbox"
|
inbox = "Inbox"
|
||||||
sent = "Sent"
|
sent = "Sent"
|
||||||
trash = "Trash"
|
trash = "Trash"
|
||||||
|
|
||||||
[accounts."hm@example.com".imap]
|
[accounts."hm@example.com".message.send.backend]
|
||||||
encryption = "tls"
|
|
||||||
host = "imap.example.com"
|
|
||||||
login = "home.manager"
|
|
||||||
port = 993
|
|
||||||
|
|
||||||
[accounts."hm@example.com".imap.passwd]
|
|
||||||
cmd = "password-command"
|
|
||||||
|
|
||||||
[accounts."hm@example.com".message.send]
|
|
||||||
backend = "smtp"
|
|
||||||
|
|
||||||
[accounts."hm@example.com".smtp]
|
|
||||||
encryption = "tls"
|
|
||||||
host = "smtp.example.com"
|
host = "smtp.example.com"
|
||||||
login = "home.manager"
|
login = "home.manager"
|
||||||
port = 465
|
port = 465
|
||||||
|
type = "smtp"
|
||||||
[accounts."hm@example.com".smtp.passwd]
|
[accounts."hm@example.com".message.send.backend.auth]
|
||||||
cmd = "password-command"
|
cmd = "password-command"
|
||||||
|
type = "password"
|
||||||
|
|
||||||
|
[accounts."hm@example.com".message.send.backend.encryption]
|
||||||
|
type = "tls"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue