From 017b12de5b899ef9b64e2c035ce257bfe95b8ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20K=C3=BChn?= Date: Thu, 29 Feb 2024 08:35:16 +0100 Subject: [PATCH] neomutt: adding unmailboxes option Adding unmailboxes option to neomutt, which adds the `unmailboxes` option it to every account.email with neomutt enabled. See https://www.mutt.org/doc/manual/#mailboxes for more. --- modules/programs/neomutt.nix | 18 +++++++++- tests/modules/programs/neomutt/default.nix | 1 + .../hm-example.com-unmailboxes-expected.conf | 34 +++++++++++++++++++ .../programs/neomutt/neomutt-unmailboxes.nix | 30 ++++++++++++++++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 tests/modules/programs/neomutt/hm-example.com-unmailboxes-expected.conf create mode 100644 tests/modules/programs/neomutt/neomutt-unmailboxes.nix diff --git a/modules/programs/neomutt.nix b/modules/programs/neomutt.nix index 1067bda1..d338a580 100644 --- a/modules/programs/neomutt.nix +++ b/modules/programs/neomutt.nix @@ -296,7 +296,12 @@ let pkgs.writeText "signature.txt" account.signature.text }"; in '' - # Generated by Home Manager. + # Generated by Home Manager.${ + optionalString cfg.unmailboxes '' + + unmailboxes * + '' + } set ssl_force_tls = ${ lib.hm.booleans.yesNo (imap.tls.enable || imap.tls.useStartTls) } @@ -397,6 +402,17 @@ in { default = true; }; + unmailboxes = mkOption { + type = types.bool; + default = false; + description = '' + Set `unmailboxes *` at the start of account configurations. + It removes previous sidebar mailboxes when sourcing an account configuration. + + See for more information. + ''; + }; + extraConfig = mkOption { type = types.lines; default = ""; diff --git a/tests/modules/programs/neomutt/default.nix b/tests/modules/programs/neomutt/default.nix index d13b870e..5666ade0 100644 --- a/tests/modules/programs/neomutt/default.nix +++ b/tests/modules/programs/neomutt/default.nix @@ -14,4 +14,5 @@ neomutt-with-signature = ./neomutt-with-signature.nix; neomutt-with-signature-command = ./neomutt-with-signature-command.nix; neomutt-with-starttls = ./neomutt-with-starttls.nix; + neomutt-unmailboxes = ./neomutt-unmailboxes.nix; } diff --git a/tests/modules/programs/neomutt/hm-example.com-unmailboxes-expected.conf b/tests/modules/programs/neomutt/hm-example.com-unmailboxes-expected.conf new file mode 100644 index 00000000..35822cee --- /dev/null +++ b/tests/modules/programs/neomutt/hm-example.com-unmailboxes-expected.conf @@ -0,0 +1,34 @@ +# Generated by Home Manager. +unmailboxes * + +set ssl_force_tls = yes +set certificate_file=/etc/ssl/certs/ca-certificates.crt + +# GPG section +set crypt_autosign = no +set crypt_opportunistic_encrypt = no +set pgp_use_gpg_agent = yes +set mbox_type = Maildir +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' +set postponed='+Drafts' +set realname='H. M. Test' +set record='+Sent' +set spoolfile='+Inbox' +set trash='+Trash' + + +# Extra configuration + + +unset signature diff --git a/tests/modules/programs/neomutt/neomutt-unmailboxes.nix b/tests/modules/programs/neomutt/neomutt-unmailboxes.nix new file mode 100644 index 00000000..162379b8 --- /dev/null +++ b/tests/modules/programs/neomutt/neomutt-unmailboxes.nix @@ -0,0 +1,30 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + imports = [ ../../accounts/email-test-accounts.nix ]; + + config = { + accounts.email.accounts = { + "hm@example.com" = { + msmtp.enable = true; + neomutt.enable = true; + imap.port = 993; + }; + }; + + programs.neomutt.enable = true; + programs.neomutt.unmailboxes = true; + + test.stubs.neomutt = { }; + + nmt.script = '' + assertFileExists home-files/.config/neomutt/hm@example.com + assertFileContent home-files/.config/neomutt/hm@example.com ${ + ./hm-example.com-unmailboxes-expected.conf + } + ''; + }; +} +