mu: allow aliases to be used by mu configuration file
This has no effect if the user does not have any aliases defined for any accounts. This will also only add `--my-address=` to only accounts that are enabled to be tracked by mu.
This commit is contained in:
parent
5d4327cff4
commit
da92196a95
|
@ -12,12 +12,14 @@ let
|
|||
# Takes the list of accounts with mu.enable = true, and generates a
|
||||
# command-line flag for initializing the mu database.
|
||||
myAddresses = let
|
||||
# List of account sets where mu.enable = true.
|
||||
# Set of email account sets where mu.enable = true.
|
||||
muAccounts =
|
||||
filter (a: a.mu.enable) (attrValues config.accounts.email.accounts);
|
||||
addrs = map (a: a.address) muAccounts;
|
||||
# Prefix --my-address= to each account's address with mu.enable.
|
||||
addMyAddress = map (addr: "--my-address=" + addr) addrs;
|
||||
# Construct list of lists containing email aliases, and flatten
|
||||
aliases = flatten (map (a: a.aliases) muAccounts);
|
||||
# Prefix --my-address= to each account's address AND all defined aliases
|
||||
addMyAddress = map (addr: "--my-address=" + addr) (addrs ++ aliases);
|
||||
in concatStringsSep " " addMyAddress;
|
||||
|
||||
in {
|
||||
|
|
|
@ -76,6 +76,7 @@ import nmt {
|
|||
./modules/programs/man
|
||||
./modules/programs/mbsync
|
||||
./modules/programs/mpv
|
||||
./modules/programs/mu
|
||||
./modules/programs/ncmpcpp
|
||||
./modules/programs/ne
|
||||
./modules/programs/neomutt
|
||||
|
|
24
tests/modules/programs/mu/basic-configuration.nix
Normal file
24
tests/modules/programs/mu/basic-configuration.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
imports = [ ../../accounts/email-test-accounts.nix ];
|
||||
|
||||
accounts.email.accounts = {
|
||||
"hm@example.com" = {
|
||||
mu.enable = true;
|
||||
aliases = [ "foo@example.com" ];
|
||||
};
|
||||
};
|
||||
|
||||
programs.mu.enable = true;
|
||||
|
||||
test.stubs.mu = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains activate \
|
||||
'if [[ ! -d "/home/hm-user/.cache/mu" ]]; then'
|
||||
|
||||
assertFileContains activate \
|
||||
'$DRY_RUN_CMD mu init --maildir=/home/hm-user/Mail --my-address=hm@example.com --my-address=foo@example.com $VERBOSE_ARG;'
|
||||
'';
|
||||
}
|
1
tests/modules/programs/mu/default.nix
Normal file
1
tests/modules/programs/mu/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ mu-basic-configuration = ./basic-configuration.nix; }
|
Loading…
Reference in a new issue