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:
Karl Hallsby 2022-02-21 21:24:27 -06:00 committed by Robert Helgesson
parent 5d4327cff4
commit da92196a95
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
4 changed files with 31 additions and 3 deletions

View file

@ -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 {

View file

@ -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

View 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;'
'';
}

View file

@ -0,0 +1 @@
{ mu-basic-configuration = ./basic-configuration.nix; }