From cb4ec90a4bbc0cadb91694ead224817fd7657a47 Mon Sep 17 00:00:00 2001 From: "Matthieu C." <886074+teto@users.noreply.github.com> Date: Sun, 23 Feb 2025 14:40:47 +0100 Subject: [PATCH] neomutt: remove empty lines prettier + more readable --- modules/programs/neomutt.nix | 83 ++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/modules/programs/neomutt.nix b/modules/programs/neomutt.nix index 13ee897f1..40005af10 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; @@ -454,43 +456,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 = [{