-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A very simple TUI mail client.
- Loading branch information
Showing
9 changed files
with
173 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ himalaya = ./himalaya.nix; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
downloads-dir = "/data/download" | ||
name = "" | ||
|
||
["hm@example.com"] | ||
default = true | ||
default-page-size = 50 | ||
email = "[email protected]" | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
with lib; | ||
|
||
{ | ||
imports = [ ../../accounts/email-test-accounts.nix ]; | ||
|
||
config = { | ||
accounts.email.accounts = { | ||
"[email protected]" = { | ||
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 | ||
} | ||
''; | ||
}; | ||
} | ||
|