mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
himalaya: add module
A very simple TUI mail client.
This commit is contained in:
parent
8eee5f5272
commit
8d3b273afe
9 changed files with 173 additions and 1 deletions
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
|
@ -84,6 +84,9 @@
|
|||
|
||||
/modules/programs/go.nix @rvolosatovs
|
||||
|
||||
/modules/programs/himalaya.nix @ambroisie
|
||||
/tests/modules/programs/himalaya @ambroisie
|
||||
|
||||
/modules/programs/home-manager.nix @rycee
|
||||
|
||||
/modules/programs/htop.nix @bjpbakker
|
||||
|
|
|
@ -332,7 +332,10 @@ let
|
|||
(mkIf (config.flavor == "gmail.com") {
|
||||
userName = mkDefault config.address;
|
||||
|
||||
imap = { host = "imap.gmail.com"; };
|
||||
imap = {
|
||||
host = "imap.gmail.com";
|
||||
port = 993;
|
||||
};
|
||||
|
||||
smtp = {
|
||||
host = "smtp.gmail.com";
|
||||
|
|
|
@ -2111,6 +2111,13 @@ in
|
|||
A new module is available: 'i18n.inputMethod'.
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
time = "2021-06-22T14:43:53+00:00";
|
||||
message = ''
|
||||
A new module is available: 'programs.himalaya'.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ let
|
|||
(loadModule ./programs/gnome-terminal.nix { })
|
||||
(loadModule ./programs/go.nix { })
|
||||
(loadModule ./programs/gpg.nix { })
|
||||
(loadModule ./programs/himalaya.nix { })
|
||||
(loadModule ./programs/home-manager.nix { })
|
||||
(loadModule ./programs/htop.nix { })
|
||||
(loadModule ./programs/i3status.nix { })
|
||||
|
|
100
modules/programs/himalaya.nix
Normal file
100
modules/programs/himalaya.nix
Normal file
|
@ -0,0 +1,100 @@
|
|||
{ 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;
|
||||
|
||||
# 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;
|
||||
smtp-starttls = account.imap.tls.useStartTls;
|
||||
} // (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;
|
||||
defaultText = literalExample "pkgs.himalaya";
|
||||
description = ''
|
||||
Package providing the <command>himalaya</command> mail client.
|
||||
'';
|
||||
};
|
||||
|
||||
settings = mkOption {
|
||||
type = tomlFormat.type;
|
||||
default = { };
|
||||
example = lib.literalExample ''
|
||||
{
|
||||
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 = { };
|
||||
example = lib.literalExample ''
|
||||
{
|
||||
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;
|
||||
};
|
||||
}
|
|
@ -53,6 +53,7 @@ import nmt {
|
|||
./modules/programs/gh
|
||||
./modules/programs/git
|
||||
./modules/programs/gpg
|
||||
./modules/programs/himalaya
|
||||
./modules/programs/htop
|
||||
./modules/programs/i3status
|
||||
./modules/programs/irsii
|
||||
|
|
1
tests/modules/programs/himalaya/default.nix
Normal file
1
tests/modules/programs/himalaya/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ himalaya = ./himalaya.nix; }
|
18
tests/modules/programs/himalaya/himalaya-expected.toml
Normal file
18
tests/modules/programs/himalaya/himalaya-expected.toml
Normal file
|
@ -0,0 +1,18 @@
|
|||
downloads-dir = "/data/download"
|
||||
name = ""
|
||||
|
||||
["hm@example.com"]
|
||||
default = true
|
||||
default-page-size = 50
|
||||
email = "hm@example.com"
|
||||
imap-host = "imap.example.com"
|
||||
imap-login = "home.manager"
|
||||
imap-passwd-cmd = "'password-command'"
|
||||
imap-port = 995
|
||||
imap-starttls = false
|
||||
name = "H. M. Test"
|
||||
smtp-host = "smtp.example.com"
|
||||
smtp-login = "home.manager"
|
||||
smtp-passwd-cmd = "'password-command'"
|
||||
smtp-port = 465
|
||||
smtp-starttls = false
|
38
tests/modules/programs/himalaya/himalaya.nix
Normal file
38
tests/modules/programs/himalaya/himalaya.nix
Normal file
|
@ -0,0 +1,38 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
imports = [ ../../accounts/email-test-accounts.nix ];
|
||||
|
||||
config = {
|
||||
accounts.email.accounts = {
|
||||
"hm@example.com" = {
|
||||
himalaya = {
|
||||
enable = true;
|
||||
|
||||
settings = { default-page-size = 50; };
|
||||
};
|
||||
|
||||
imap.port = 995;
|
||||
smtp.port = 465;
|
||||
};
|
||||
};
|
||||
|
||||
programs.himalaya = {
|
||||
enable = true;
|
||||
settings = { downloads-dir = "/data/download"; };
|
||||
};
|
||||
|
||||
nixpkgs.overlays =
|
||||
[ (self: super: { himalaya = pkgs.writeScriptBin "dummy-alot" ""; }) ];
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/himalaya/config.toml
|
||||
assertFileContent home-files/.config/himalaya/config.toml ${
|
||||
./himalaya-expected.toml
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in a new issue