From da92196a95c3aeaa6e8336be2864ef02245ad730 Mon Sep 17 00:00:00 2001 From: Karl Hallsby Date: Mon, 21 Feb 2022 21:24:27 -0600 Subject: [PATCH] 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. --- modules/programs/mu.nix | 8 ++++--- tests/default.nix | 1 + .../programs/mu/basic-configuration.nix | 24 +++++++++++++++++++ tests/modules/programs/mu/default.nix | 1 + 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 tests/modules/programs/mu/basic-configuration.nix create mode 100644 tests/modules/programs/mu/default.nix diff --git a/modules/programs/mu.nix b/modules/programs/mu.nix index 233624d14..58b8b3dff 100644 --- a/modules/programs/mu.nix +++ b/modules/programs/mu.nix @@ -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 { diff --git a/tests/default.nix b/tests/default.nix index 35cbe1d9e..c3bd09f77 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -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 diff --git a/tests/modules/programs/mu/basic-configuration.nix b/tests/modules/programs/mu/basic-configuration.nix new file mode 100644 index 000000000..1e1deeead --- /dev/null +++ b/tests/modules/programs/mu/basic-configuration.nix @@ -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;' + ''; +} diff --git a/tests/modules/programs/mu/default.nix b/tests/modules/programs/mu/default.nix new file mode 100644 index 000000000..bdd8b1560 --- /dev/null +++ b/tests/modules/programs/mu/default.nix @@ -0,0 +1 @@ +{ mu-basic-configuration = ./basic-configuration.nix; }