diff --git a/modules/programs/neomutt.nix b/modules/programs/neomutt.nix index 13ee897f1..8ef1a45cf 100644 --- a/modules/programs/neomutt.nix +++ b/modules/programs/neomutt.nix @@ -237,14 +237,16 @@ let else ''named-mailboxes "${extra.name}" "${mailboxroot}/${extra.mailbox}"'') account.neomutt.extraMailboxes; - in with account; '' - # register account ${name} - ${optionalString account.neomutt.showDefaultMailbox - ''${mailboxes} "${mailroot}/${folders.inbox}"''} - ${extraMailboxes} - ${hookName} ${mailroot}/ " \ - source ${accountFilename account} " - ''; + in with account; + [ "## register account ${name}" ] + ++ optional account.neomutt.showDefaultMailbox + ''${mailboxes} "${mailroot}/${folders.inbox}"'' ++ [ + extraMailboxes + '' + ${hookName} ${mailroot}/ " \ + source ${accountFilename account} " + '' + ]; mraSection = account: with account; @@ -300,7 +302,7 @@ let "set signature = ${ pkgs.writeText "signature.txt" account.signature.text }"; - in '' + in concatStringsSep "\n" (['' # Generated by Home Manager.${ optionalString cfg.unmailboxes '' @@ -323,21 +325,18 @@ let # MTA section ${optionsStr (mtaSection account)} + ''] ++ (lib.optional (cfg.checkStatsInterval != null) mailCheckSection) + ++ (lib.optional cfg.sidebar.enable sidebarSection) ++ ['' + # MRA section + ${mraSection account} - ${optionalString (cfg.checkStatsInterval != null) mailCheckSection} + # Extra configuration + ${account.neomutt.extraConfig} - ${optionalString cfg.sidebar.enable sidebarSection} - - # MRA section - ${mraSection account} - - # Extra configuration - ${account.neomutt.extraConfig} - - ${signature} - '' - + optionalString (account.notmuch.enable && account.notmuch.neomutt.enable) - (notmuchSection account); + ${signature} + ''] + ++ lib.optional (account.notmuch.enable && account.notmuch.neomutt.enable) + (notmuchSection account)); in { options = { @@ -454,43 +453,40 @@ in { # otherwise use the first neomutt account as primary. primary = head (filter (a: a.primary) neomuttAccounts ++ neomuttAccounts); - in '' - # Generated by Home Manager. - set header_cache = "${config.xdg.cacheHome}/neomutt/headers/" - set message_cachedir = "${config.xdg.cacheHome}/neomutt/messages/" - set editor = "${cfg.editor}" - set implicit_autoview = yes - set crypt_use_gpgme = yes + in concatStringsSep "\n" ([ + "# Generated by Home Manager." + ''set header_cache = "${config.xdg.cacheHome}/neomutt/headers/"'' + ''set message_cachedir = "${config.xdg.cacheHome}/neomutt/messages/"'' + ''set editor = "${cfg.editor}"'' + "set implicit_autoview = yes" + "set crypt_use_gpgme = yes" + "alternative_order text/enriched text/plain text" + "set delete = yes" + (optionalString cfg.vimKeys + "source ${pkgs.neomutt}/share/doc/neomutt/vim-keys/vim-keys.rc") + ] ++ (lib.optionals (cfg.binds != [ ]) [ + '' - alternative_order text/enriched text/plain text + # Binds'' + bindSection + ]) ++ [ + '' - set delete = yes - - ${optionalString cfg.vimKeys - "source ${pkgs.neomutt}/share/doc/neomutt/vim-keys/vim-keys.rc"} - - # Binds - ${bindSection} - - # Macros - ${macroSection} - - # Register accounts - ${ - optionalString (accountCommandNeeded) '' - set account_command = '${accountCommand}/bin/account-command.sh' - '' - }${concatMapStringsSep "\n" registerAccount neomuttAccounts} - - ${optionalString cfg.sourcePrimaryAccount '' + # Macros'' + macroSection + "# Register accounts" + (optionalString (accountCommandNeeded) '' + set account_command = '${accountCommand}/bin/account-command.sh' + '') + ] ++ (lib.flatten (map registerAccount neomuttAccounts)) ++ [ + (optionalString cfg.sourcePrimaryAccount '' # Source primary account - source ${accountFilename primary}''} - - # Extra configuration - ${optionsStr cfg.settings} - - ${cfg.extraConfig} - ''; + source ${accountFilename primary} + '') + "# Extra configuration" + (optionsStr cfg.settings) + cfg.extraConfig + ]); }; assertions = [{ diff --git a/tests/modules/programs/neomutt/hm-example.com-expected b/tests/modules/programs/neomutt/hm-example.com-expected index e31f0d01a..28d4c56bb 100644 --- a/tests/modules/programs/neomutt/hm-example.com-expected +++ b/tests/modules/programs/neomutt/hm-example.com-expected @@ -13,10 +13,6 @@ set sort = "threads" set smtp_pass="`password-command`" set smtp_url='smtps://home.manager@smtp.example.com' - - - - # MRA section set folder='/home/hm-user/Mail/hm@example.com' set from='hm@example.com' @@ -32,6 +28,7 @@ color status cyan default unset signature + # notmuch section set nm_default_uri = "notmuch:///home/hm-user/Mail" virtual-mailboxes "My INBOX" "notmuch://?query=tag%3Ainbox" diff --git a/tests/modules/programs/neomutt/hm-example.com-gpg-expected.conf b/tests/modules/programs/neomutt/hm-example.com-gpg-expected.conf index f37710719..4c8d65e16 100644 --- a/tests/modules/programs/neomutt/hm-example.com-gpg-expected.conf +++ b/tests/modules/programs/neomutt/hm-example.com-gpg-expected.conf @@ -13,10 +13,6 @@ set sort = "threads" set smtp_pass="`password-command`" set smtp_url='smtps://home.manager@smtp.example.com' - - - - # MRA section set folder='/home/hm-user/Mail/hm@example.com' set from='hm@example.com' diff --git a/tests/modules/programs/neomutt/hm-example.com-imap-expected.conf b/tests/modules/programs/neomutt/hm-example.com-imap-expected.conf index f5e9116d1..e87fbdc3f 100644 --- a/tests/modules/programs/neomutt/hm-example.com-imap-expected.conf +++ b/tests/modules/programs/neomutt/hm-example.com-imap-expected.conf @@ -13,10 +13,6 @@ set sort = "threads" set smtp_pass="`password-command`" set smtp_url='smtps://home.manager@smtp.example.com' - - - - # MRA section set folder='imaps://home.manager@imap.example.com:993' set from='hm@example.com' diff --git a/tests/modules/programs/neomutt/hm-example.com-msmtp-expected.conf b/tests/modules/programs/neomutt/hm-example.com-msmtp-expected.conf index 6d4a845d0..12c7d23d5 100644 --- a/tests/modules/programs/neomutt/hm-example.com-msmtp-expected.conf +++ b/tests/modules/programs/neomutt/hm-example.com-msmtp-expected.conf @@ -12,10 +12,6 @@ set sort = "threads" # MTA section set sendmail='msmtpq --read-envelope-from --read-recipients' - - - - # MRA section set folder='/home/hm-user/Mail/hm@example.com' set from='hm@example.com' diff --git a/tests/modules/programs/neomutt/hm-example.com-no-folder-change-expected.conf b/tests/modules/programs/neomutt/hm-example.com-no-folder-change-expected.conf index 44def8ae7..a5a8382a9 100644 --- a/tests/modules/programs/neomutt/hm-example.com-no-folder-change-expected.conf +++ b/tests/modules/programs/neomutt/hm-example.com-no-folder-change-expected.conf @@ -12,10 +12,6 @@ set sort = "threads" # MTA section set sendmail='msmtpq --read-envelope-from --read-recipients' - - - - # MRA section set from='hm@example.com' set postponed='+Drafts' diff --git a/tests/modules/programs/neomutt/hm-example.com-signature-command-expected b/tests/modules/programs/neomutt/hm-example.com-signature-command-expected index 57825af4e..ab4c63824 100644 --- a/tests/modules/programs/neomutt/hm-example.com-signature-command-expected +++ b/tests/modules/programs/neomutt/hm-example.com-signature-command-expected @@ -13,10 +13,6 @@ set sort = "threads" set smtp_pass="`password-command`" set smtp_url='smtps://home.manager@smtp.example.com' - - - - # MRA section set folder='/home/hm-user/Mail/hm@example.com' set from='hm@example.com' @@ -32,6 +28,7 @@ color status cyan default set signature = "/nix/store/00000000000000000000000000000000-signature|" + # notmuch section set nm_default_uri = "notmuch:///home/hm-user/Mail" virtual-mailboxes "My INBOX" "notmuch://?query=tag%3Ainbox" diff --git a/tests/modules/programs/neomutt/hm-example.com-signature-expected b/tests/modules/programs/neomutt/hm-example.com-signature-expected index c17314ed5..017bd234e 100644 --- a/tests/modules/programs/neomutt/hm-example.com-signature-expected +++ b/tests/modules/programs/neomutt/hm-example.com-signature-expected @@ -13,10 +13,6 @@ set sort = "threads" set smtp_pass="`password-command`" set smtp_url='smtps://home.manager@smtp.example.com' - - - - # MRA section set folder='/home/hm-user/Mail/hm@example.com' set from='hm@example.com' @@ -32,6 +28,7 @@ color status cyan default set signature = /nix/store/00000000000000000000000000000000-signature.txt + # notmuch section set nm_default_uri = "notmuch:///home/hm-user/Mail" virtual-mailboxes "My INBOX" "notmuch://?query=tag%3Ainbox" diff --git a/tests/modules/programs/neomutt/hm-example.com-starttls-expected b/tests/modules/programs/neomutt/hm-example.com-starttls-expected index 59aa3d1cd..7dd5a8edc 100644 --- a/tests/modules/programs/neomutt/hm-example.com-starttls-expected +++ b/tests/modules/programs/neomutt/hm-example.com-starttls-expected @@ -13,10 +13,6 @@ set sort = "threads" set smtp_pass="`password-command`" set smtp_url='smtp://home.manager@smtp.example.com' - - - - # MRA section set folder='/home/hm-user/Mail/hm@example.com' set from='hm@example.com' @@ -32,6 +28,7 @@ color status cyan default unset signature + # notmuch section set nm_default_uri = "notmuch:///home/hm-user/Mail" virtual-mailboxes "My INBOX" "notmuch://?query=tag%3Ainbox" diff --git a/tests/modules/programs/neomutt/hm-example.com-unmailboxes-expected.conf b/tests/modules/programs/neomutt/hm-example.com-unmailboxes-expected.conf index 35822ceee..053a39204 100644 --- a/tests/modules/programs/neomutt/hm-example.com-unmailboxes-expected.conf +++ b/tests/modules/programs/neomutt/hm-example.com-unmailboxes-expected.conf @@ -14,10 +14,6 @@ set sort = "threads" # MTA section set sendmail='msmtpq --read-envelope-from --read-recipients' - - - - # MRA section set folder='/home/hm-user/Mail/hm@example.com' set from='hm@example.com' diff --git a/tests/modules/programs/neomutt/neomutt-expected.conf b/tests/modules/programs/neomutt/neomutt-expected.conf index 2a45234dd..52e6db9db 100644 --- a/tests/modules/programs/neomutt/neomutt-expected.conf +++ b/tests/modules/programs/neomutt/neomutt-expected.conf @@ -4,31 +4,22 @@ set message_cachedir = "/home/hm-user/.cache/neomutt/messages/" set editor = "$EDITOR" set implicit_autoview = yes set crypt_use_gpgme = yes - alternative_order text/enriched text/plain text - set delete = yes - -# Binds - - # Macros - # Register accounts -# register account hm@example.com + +## register account hm@example.com mailboxes "/home/hm-user/Mail/hm@example.com/Inbox" folder-hook /home/hm-user/Mail/hm@example.com/ " \ - source /home/hm-user/.config/neomutt/hm@example.com " - + source /home/hm-user/.config/neomutt/hm@example.com " # Source primary account source /home/hm-user/.config/neomutt/hm@example.com # Extra configuration - - diff --git a/tests/modules/programs/neomutt/neomutt-not-primary-expected.conf b/tests/modules/programs/neomutt/neomutt-not-primary-expected.conf index 47dc81739..57ee6bce0 100644 --- a/tests/modules/programs/neomutt/neomutt-not-primary-expected.conf +++ b/tests/modules/programs/neomutt/neomutt-not-primary-expected.conf @@ -4,31 +4,22 @@ set message_cachedir = "/home/hm-user/.cache/neomutt/messages/" set editor = "$EDITOR" set implicit_autoview = yes set crypt_use_gpgme = yes - alternative_order text/enriched text/plain text - set delete = yes - -# Binds - - # Macros - # Register accounts -# register account hm-account + +## register account hm-account mailboxes "/home/hm-user/Mail/hm-account/Inbox" folder-hook /home/hm-user/Mail/hm-account/ " \ - source /home/hm-user/.config/neomutt/hm-account " - + source /home/hm-user/.config/neomutt/hm-account " # Source primary account source /home/hm-user/.config/neomutt/hm-account # Extra configuration - - diff --git a/tests/modules/programs/neomutt/neomutt-not-primary.nix b/tests/modules/programs/neomutt/neomutt-not-primary.nix index db1f2de64..8389f9709 100644 --- a/tests/modules/programs/neomutt/neomutt-not-primary.nix +++ b/tests/modules/programs/neomutt/neomutt-not-primary.nix @@ -10,7 +10,7 @@ nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc - assertFileContent home-files/.config/neomutt/neomuttrc ${ + assertFileContent $(normalizeStorePaths home-files/.config/neomutt/neomuttrc) ${ ./neomutt-not-primary-expected.conf } ''; diff --git a/tests/modules/programs/neomutt/neomutt-with-binds-expected.conf b/tests/modules/programs/neomutt/neomutt-with-binds-expected.conf index 05736749f..8c25c3b09 100644 --- a/tests/modules/programs/neomutt/neomutt-with-binds-expected.conf +++ b/tests/modules/programs/neomutt/neomutt-with-binds-expected.conf @@ -4,13 +4,10 @@ set message_cachedir = "/home/hm-user/.cache/neomutt/messages/" set editor = "$EDITOR" set implicit_autoview = yes set crypt_use_gpgme = yes - alternative_order text/enriched text/plain text - set delete = yes - # Binds bind editor "complete-query" bind index,pager \Cp "sidebar-prev" @@ -18,19 +15,16 @@ bind index,pager \Cp "sidebar-prev" # Macros macro index s "?" macro index,pager c "?^K=" - # Register accounts -# register account hm@example.com + +## register account hm@example.com mailboxes "/home/hm-user/Mail/hm@example.com/Inbox" folder-hook /home/hm-user/Mail/hm@example.com/ " \ - source /home/hm-user/.config/neomutt/hm@example.com " - + source /home/hm-user/.config/neomutt/hm@example.com " # Source primary account source /home/hm-user/.config/neomutt/hm@example.com # Extra configuration - - diff --git a/tests/modules/programs/neomutt/neomutt-with-binds-with-warning.nix b/tests/modules/programs/neomutt/neomutt-with-binds-with-warning.nix index f9d144dfd..bb0a0f89b 100644 --- a/tests/modules/programs/neomutt/neomutt-with-binds-with-warning.nix +++ b/tests/modules/programs/neomutt/neomutt-with-binds-with-warning.nix @@ -52,10 +52,10 @@ nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc assertFileExists home-files/.config/neomutt/hm@example.com - assertFileContent home-files/.config/neomutt/neomuttrc ${ + assertFileContent $(normalizeStorePaths home-files/.config/neomutt/neomuttrc) ${ ./neomutt-with-binds-expected.conf } - assertFileContent home-files/.config/neomutt/hm@example.com ${ + assertFileContent $(normalizeStorePaths home-files/.config/neomutt/hm@example.com) ${ ./hm-example.com-expected } ''; diff --git a/tests/modules/programs/neomutt/neomutt-with-binds.nix b/tests/modules/programs/neomutt/neomutt-with-binds.nix index 7f97ae9e8..6fd8b8ff8 100644 --- a/tests/modules/programs/neomutt/neomutt-with-binds.nix +++ b/tests/modules/programs/neomutt/neomutt-with-binds.nix @@ -48,10 +48,10 @@ nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc assertFileExists home-files/.config/neomutt/hm@example.com - assertFileContent home-files/.config/neomutt/neomuttrc ${ + assertFileContent $(normalizeStorePaths home-files/.config/neomutt/neomuttrc) ${ ./neomutt-with-binds-expected.conf } - assertFileContent home-files/.config/neomutt/hm@example.com ${ + assertFileContent $(normalizeStorePaths home-files/.config/neomutt/hm@example.com) ${ ./hm-example.com-expected } ''; diff --git a/tests/modules/programs/neomutt/neomutt-with-gpg.nix b/tests/modules/programs/neomutt/neomutt-with-gpg.nix index 1f542d747..9b43fc703 100644 --- a/tests/modules/programs/neomutt/neomutt-with-gpg.nix +++ b/tests/modules/programs/neomutt/neomutt-with-gpg.nix @@ -17,7 +17,7 @@ nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc assertFileExists home-files/.config/neomutt/hm@example.com - assertFileContent home-files/.config/neomutt/neomuttrc ${ + assertFileContent $(normalizeStorePaths home-files/.config/neomutt/neomuttrc) ${ ./neomutt-expected.conf } assertFileContent home-files/.config/neomutt/hm@example.com ${ diff --git a/tests/modules/programs/neomutt/neomutt-with-imap-expected.conf b/tests/modules/programs/neomutt/neomutt-with-imap-expected.conf index 02f03f6ec..01b5955c4 100644 --- a/tests/modules/programs/neomutt/neomutt-with-imap-expected.conf +++ b/tests/modules/programs/neomutt/neomutt-with-imap-expected.conf @@ -4,32 +4,23 @@ set message_cachedir = "/home/hm-user/.cache/neomutt/messages/" set editor = "$EDITOR" set implicit_autoview = yes set crypt_use_gpgme = yes - alternative_order text/enriched text/plain text - set delete = yes - -# Binds - - # Macros - # Register accounts set account_command = '/nix/store/00000000000000000000000000000000-account-command.sh/bin/account-command.sh' -# register account hm@example.com + +## register account hm@example.com mailboxes "imaps://home.manager@imap.example.com:993/Inbox" account-hook imaps://home.manager@imap.example.com:993/ " \ - source /home/hm-user/.config/neomutt/hm@example.com " - + source /home/hm-user/.config/neomutt/hm@example.com " # Source primary account source /home/hm-user/.config/neomutt/hm@example.com # Extra configuration - - diff --git a/tests/modules/programs/neomutt/neomutt-with-imap-type-mailboxes-expected.conf b/tests/modules/programs/neomutt/neomutt-with-imap-type-mailboxes-expected.conf index 51c6c6b9f..5a7c5a645 100644 --- a/tests/modules/programs/neomutt/neomutt-with-imap-type-mailboxes-expected.conf +++ b/tests/modules/programs/neomutt/neomutt-with-imap-type-mailboxes-expected.conf @@ -4,34 +4,25 @@ set message_cachedir = "/home/hm-user/.cache/neomutt/messages/" set editor = "$EDITOR" set implicit_autoview = yes set crypt_use_gpgme = yes - alternative_order text/enriched text/plain text - set delete = yes - -# Binds - - # Macros - # Register accounts set account_command = '/nix/store/00000000000000000000000000000000-account-command.sh/bin/account-command.sh' -# register account hm@example.com + +## register account hm@example.com named-mailboxes "someCustomName" "/home/hm-user/Mail/hm@example.com/Inbox" mailboxes "/home/hm-user/Mail/hm@example.com/Sent" named-mailboxes "Spam" "imaps://home.manager@imap.example.com:993/Junk Email" mailboxes "/home/hm-user/Mail/hm@example.com/Trash" folder-hook /home/hm-user/Mail/hm@example.com/ " \ - source /home/hm-user/.config/neomutt/hm@example.com " - + source /home/hm-user/.config/neomutt/hm@example.com " # Source primary account source /home/hm-user/.config/neomutt/hm@example.com # Extra configuration - - diff --git a/tests/modules/programs/neomutt/neomutt-with-named-mailboxes-expected.conf b/tests/modules/programs/neomutt/neomutt-with-named-mailboxes-expected.conf index 605b5ed6d..cb2585f32 100644 --- a/tests/modules/programs/neomutt/neomutt-with-named-mailboxes-expected.conf +++ b/tests/modules/programs/neomutt/neomutt-with-named-mailboxes-expected.conf @@ -4,33 +4,24 @@ set message_cachedir = "/home/hm-user/.cache/neomutt/messages/" set editor = "$EDITOR" set implicit_autoview = yes set crypt_use_gpgme = yes - alternative_order text/enriched text/plain text - set delete = yes - -# Binds - - # Macros - # Register accounts -# register account hm@example.com + +## register account hm@example.com named-mailboxes "someCustomName" "/home/hm-user/Mail/hm@example.com/Inbox" mailboxes "/home/hm-user/Mail/hm@example.com/Sent" named-mailboxes "Spam" "/home/hm-user/Mail/hm@example.com/Junk Email" mailboxes "/home/hm-user/Mail/hm@example.com/Trash" folder-hook /home/hm-user/Mail/hm@example.com/ " \ - source /home/hm-user/.config/neomutt/hm@example.com " - + source /home/hm-user/.config/neomutt/hm@example.com " # Source primary account source /home/hm-user/.config/neomutt/hm@example.com # Extra configuration - - diff --git a/tests/modules/programs/neomutt/neomutt-with-named-mailboxes.nix b/tests/modules/programs/neomutt/neomutt-with-named-mailboxes.nix index 1d1d2fa47..bbd3afb5a 100644 --- a/tests/modules/programs/neomutt/neomutt-with-named-mailboxes.nix +++ b/tests/modules/programs/neomutt/neomutt-with-named-mailboxes.nix @@ -31,7 +31,7 @@ nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc assertFileExists home-files/.config/neomutt/hm@example.com - assertFileContent home-files/.config/neomutt/neomuttrc ${ + assertFileContent $(normalizeStorePaths home-files/.config/neomutt/neomuttrc) ${ ./neomutt-with-named-mailboxes-expected.conf } assertFileContent home-files/.config/neomutt/hm@example.com ${ diff --git a/tests/modules/programs/neomutt/neomutt-with-signature.nix b/tests/modules/programs/neomutt/neomutt-with-signature.nix index e8361e0a2..347db9a3d 100644 --- a/tests/modules/programs/neomutt/neomutt-with-signature.nix +++ b/tests/modules/programs/neomutt/neomutt-with-signature.nix @@ -29,7 +29,7 @@ nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc assertFileExists home-files/.config/neomutt/hm@example.com - assertFileContent home-files/.config/neomutt/neomuttrc ${ + assertFileContent $(normalizeStorePaths home-files/.config/neomutt/neomuttrc) ${ ./neomutt-expected.conf } expectedSignature=$(normalizeStorePaths "home-files/.config/neomutt/hm@example.com")