mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
neverest: init at 1.0.0-beta
This commit is contained in:
parent
ff1c364654
commit
4bbfae1fa8
6 changed files with 216 additions and 0 deletions
|
@ -162,6 +162,7 @@ let
|
|||
./programs/ne.nix
|
||||
./programs/neomutt.nix
|
||||
./programs/neovim.nix
|
||||
./programs/neverest.nix
|
||||
./programs/newsboat.nix
|
||||
./programs/nheko.nix
|
||||
./programs/nix-index.nix
|
||||
|
|
165
modules/programs/neverest.nix
Normal file
165
modules/programs/neverest.nix
Normal file
|
@ -0,0 +1,165 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (config.programs) neverest;
|
||||
|
||||
toml = pkgs.formats.toml { };
|
||||
|
||||
backendType = lib.types.enum [ "imap" "maildir" "notmuch" ];
|
||||
|
||||
mkEncryptionConfig = tls:
|
||||
if tls.useStartTls then
|
||||
"start-tls"
|
||||
else if tls.enable then
|
||||
"tls"
|
||||
else
|
||||
"none";
|
||||
|
||||
mkBackendConfig = account:
|
||||
let
|
||||
hmAccount = config.accounts.email.accounts.${account.name};
|
||||
notmuchEnabled = account.backend == "notmuch"
|
||||
&& hmAccount.notmuch.enable or false;
|
||||
imapEnabled = account.backend == "imap" && !isNull hmAccount.imap
|
||||
&& !notmuchEnabled;
|
||||
maildirEnabled = account.backend == "maildir" && !isNull hmAccount.maildir
|
||||
&& !imapEnabled && !notmuchEnabled;
|
||||
|
||||
in lib.optionalAttrs (imapEnabled) {
|
||||
type = "imap";
|
||||
host = hmAccount.imap.host;
|
||||
port = hmAccount.imap.port;
|
||||
encryption = mkEncryptionConfig hmAccount.imap.tls;
|
||||
login = hmAccount.userName;
|
||||
passwd.cmd = builtins.concatStringsSep " " hmAccount.passwordCommand;
|
||||
|
||||
} // lib.optionalAttrs (maildirEnabled) {
|
||||
type = "maildir";
|
||||
root-dir = hmAccount.maildir.absPath;
|
||||
|
||||
} // lib.optionalAttrs (notmuchEnabled) {
|
||||
type = "notmuch";
|
||||
database-path = config.accounts.email.maildirBasePath;
|
||||
};
|
||||
|
||||
mkAccountConfig = accountName: account:
|
||||
let
|
||||
leftBackend = { backend = mkBackendConfig account.left; };
|
||||
rightBackend = { backend = mkBackendConfig account.right; };
|
||||
|
||||
in lib.recursiveUpdate account.settings {
|
||||
left = lib.recursiveUpdate leftBackend account.left.settings;
|
||||
right = lib.recursiveUpdate rightBackend account.right.settings;
|
||||
};
|
||||
|
||||
in {
|
||||
meta.maintainers = with lib.hm.maintainers; [ soywod ];
|
||||
|
||||
options = {
|
||||
programs.neverest = {
|
||||
enable = lib.mkEnableOption "the email synchronizer Neverest CLI";
|
||||
|
||||
package = lib.mkPackageOption pkgs "neverest" { };
|
||||
|
||||
accounts = lib.mkOption {
|
||||
description = ''
|
||||
Accounts configuration.
|
||||
'';
|
||||
type = lib.types.attrsOf (lib.types.submodule {
|
||||
options = {
|
||||
left = lib.mkOption {
|
||||
description = ''
|
||||
Account configuration of the left backend.
|
||||
See <https://pimalaya.org/neverest/cli/latest/configuration/#account-configuration> for supported values.
|
||||
'';
|
||||
type = lib.types.submodule {
|
||||
options = {
|
||||
backend = lib.mkOption {
|
||||
type = backendType;
|
||||
description = ''
|
||||
The type of the left backend.
|
||||
'';
|
||||
};
|
||||
|
||||
name = lib.mkOption {
|
||||
type = lib.types.enum
|
||||
(builtins.attrNames config.accounts.email.accounts);
|
||||
description = ''
|
||||
The name of the Home Manager email account to use
|
||||
as the left side of the current Neverest account.
|
||||
'';
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.submodule { freeformType = toml.type; };
|
||||
default = { };
|
||||
description = ''
|
||||
Additional account configuration of the left backend.
|
||||
See <https://pimalaya.org/neverest/cli/latest/configuration/#account-configuration> for supported values.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
right = lib.mkOption {
|
||||
description = ''
|
||||
Account configuration of the right backend.
|
||||
See <https://pimalaya.org/neverest/cli/latest/configuration/#account-configuration> for supported values.
|
||||
'';
|
||||
type = lib.types.submodule {
|
||||
options = {
|
||||
backend = lib.mkOption {
|
||||
type = backendType;
|
||||
description = ''
|
||||
The type of the right backend.
|
||||
'';
|
||||
};
|
||||
|
||||
name = lib.mkOption {
|
||||
type = lib.types.enum
|
||||
(builtins.attrNames config.accounts.email.accounts);
|
||||
description = ''
|
||||
The name of the Home Manager email account to use
|
||||
as the right side of the current Neverest account.
|
||||
'';
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.submodule { freeformType = toml.type; };
|
||||
default = { };
|
||||
description = ''
|
||||
Additional account configuration of the right backend.
|
||||
See <https://pimalaya.org/neverest/cli/latest/configuration/#account-configuration> for supported values.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.submodule { freeformType = toml.type; };
|
||||
default = { };
|
||||
description = ''
|
||||
Additional account configuration.
|
||||
See <https://pimalaya.org/neverest/cli/latest/configuration/#account-configuration> for supported values.
|
||||
'';
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf neverest.enable {
|
||||
home.packages = [ neverest.package ];
|
||||
|
||||
xdg = {
|
||||
configFile."neverest/config.toml".source =
|
||||
toml.generate "neverest-config.toml" {
|
||||
accounts = lib.mapAttrs mkAccountConfig neverest.accounts;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -110,6 +110,7 @@ in import nmtSrc {
|
|||
./modules/programs/ne
|
||||
./modules/programs/neomutt
|
||||
./modules/programs/neovim
|
||||
./modules/programs/neverest
|
||||
./modules/programs/newsboat
|
||||
./modules/programs/nheko
|
||||
./modules/programs/nix-index
|
||||
|
|
14
tests/modules/programs/neverest/basic-expected.toml
Normal file
14
tests/modules/programs/neverest/basic-expected.toml
Normal file
|
@ -0,0 +1,14 @@
|
|||
[accounts.imap-maildir]
|
||||
[accounts.imap-maildir.left.backend]
|
||||
encryption = "tls"
|
||||
host = "imap.example.com"
|
||||
login = "home.manager"
|
||||
port = 993
|
||||
type = "imap"
|
||||
|
||||
[accounts.imap-maildir.left.backend.passwd]
|
||||
cmd = "password-command"
|
||||
|
||||
[accounts.imap-maildir.right.backend]
|
||||
root-dir = "/home/hm-user/Mail/hm@example.com"
|
||||
type = "maildir"
|
34
tests/modules/programs/neverest/basic.nix
Normal file
34
tests/modules/programs/neverest/basic.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
imports = [ ../../accounts/email-test-accounts.nix ];
|
||||
|
||||
programs.neverest = {
|
||||
enable = true;
|
||||
accounts = {
|
||||
"imap-maildir" = {
|
||||
left = {
|
||||
backend = "imap";
|
||||
name = "hm@example.com";
|
||||
settings = { backend.port = 993; };
|
||||
};
|
||||
right = {
|
||||
backend = "maildir";
|
||||
name = "hm@example.com";
|
||||
};
|
||||
settings = { left.backend.port = 143; };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
test.stubs.neverest = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/neverest/config.toml
|
||||
assertFileContent home-files/.config/neverest/config.toml ${
|
||||
./basic-expected.toml
|
||||
}
|
||||
'';
|
||||
}
|
1
tests/modules/programs/neverest/default.nix
Normal file
1
tests/modules/programs/neverest/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ neverest-basic = ./basic.nix; }
|
Loading…
Reference in a new issue