mirror of
https://github.com/nix-community/home-manager.git
synced 2024-12-14 11:57:55 +00:00
neomutt: add support for signature command (#2899)
Neomutt will run the given command (which can be a string or a path) and take the output from stdout and use it as the signature for your email. Co-authored-by: Nicolas Berbiche <nicolas@normie.dev>
This commit is contained in:
parent
778af87a98
commit
f8b51be714
11 changed files with 197 additions and 6 deletions
|
@ -44,6 +44,15 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
command = mkOption {
|
||||||
|
type = with types; nullOr path;
|
||||||
|
default = null;
|
||||||
|
example = literalExpression ''
|
||||||
|
pkgs.writeScript "signature" "echo This is my signature"
|
||||||
|
'';
|
||||||
|
description = "A command that generates a signature.";
|
||||||
|
};
|
||||||
|
|
||||||
showSignature = mkOption {
|
showSignature = mkOption {
|
||||||
type = types.enum [ "append" "attach" "none" ];
|
type = types.enum [ "append" "attach" "none" ];
|
||||||
default = "none";
|
default = "none";
|
||||||
|
|
|
@ -196,7 +196,16 @@ let
|
||||||
|
|
||||||
accountStr = account:
|
accountStr = account:
|
||||||
with account;
|
with account;
|
||||||
''
|
let
|
||||||
|
signature = if account.signature.showSignature == "none" then
|
||||||
|
"unset signature"
|
||||||
|
else if account.signature.command != null then
|
||||||
|
''set signature = "${account.signature.command}|"''
|
||||||
|
else
|
||||||
|
"set signature = ${
|
||||||
|
pkgs.writeText "signature.txt" account.signature.text
|
||||||
|
}";
|
||||||
|
in ''
|
||||||
# Generated by Home Manager.
|
# Generated by Home Manager.
|
||||||
set ssl_force_tls = yes
|
set ssl_force_tls = yes
|
||||||
set certificate_file=${toString config.accounts.email.certificatesFile}
|
set certificate_file=${toString config.accounts.email.certificatesFile}
|
||||||
|
@ -223,11 +232,9 @@ let
|
||||||
|
|
||||||
# Extra configuration
|
# Extra configuration
|
||||||
${account.neomutt.extraConfig}
|
${account.neomutt.extraConfig}
|
||||||
'' + (if (account.signature.showSignature == "none") then ''
|
|
||||||
unset signature
|
${signature}
|
||||||
'' else ''
|
'' + optionalString account.notmuch.enable (notmuchSection account);
|
||||||
set signature = ${pkgs.writeText "signature.txt" account.signature.text}
|
|
||||||
'') + optionalString account.notmuch.enable (notmuchSection account);
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
options = {
|
options = {
|
||||||
|
|
|
@ -9,4 +9,6 @@
|
||||||
neomutt-with-gpg = ./neomutt-with-gpg.nix;
|
neomutt-with-gpg = ./neomutt-with-gpg.nix;
|
||||||
neomutt-no-folder-change = ./neomutt-no-folder-change.nix;
|
neomutt-no-folder-change = ./neomutt-no-folder-change.nix;
|
||||||
neomutt-with-named-mailboxes = ./neomutt-with-named-mailboxes.nix;
|
neomutt-with-named-mailboxes = ./neomutt-with-named-mailboxes.nix;
|
||||||
|
neomutt-with-signature = ./neomutt-with-signature.nix;
|
||||||
|
neomutt-with-signature-command = ./neomutt-with-signature-command.nix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ set trash='+Trash'
|
||||||
# Extra configuration
|
# Extra configuration
|
||||||
color status cyan default
|
color status cyan default
|
||||||
|
|
||||||
|
|
||||||
unset signature
|
unset signature
|
||||||
# notmuch section
|
# notmuch section
|
||||||
set nm_default_uri = "notmuch:///home/hm-user/Mail"
|
set nm_default_uri = "notmuch:///home/hm-user/Mail"
|
||||||
|
|
|
@ -30,4 +30,5 @@ set trash='+Trash'
|
||||||
|
|
||||||
# Extra configuration
|
# Extra configuration
|
||||||
|
|
||||||
|
|
||||||
unset signature
|
unset signature
|
||||||
|
|
|
@ -30,4 +30,5 @@ set trash='+Trash'
|
||||||
# Extra configuration
|
# Extra configuration
|
||||||
color status cyan default
|
color status cyan default
|
||||||
|
|
||||||
|
|
||||||
unset signature
|
unset signature
|
||||||
|
|
|
@ -28,4 +28,5 @@ set trash='+Trash'
|
||||||
|
|
||||||
# Extra configuration
|
# Extra configuration
|
||||||
|
|
||||||
|
|
||||||
unset signature
|
unset signature
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
# Generated by Home Manager.
|
||||||
|
set ssl_force_tls = yes
|
||||||
|
set certificate_file=/etc/ssl/certs/ca-certificates.crt
|
||||||
|
|
||||||
|
# GPG section
|
||||||
|
set crypt_use_gpgme = yes
|
||||||
|
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 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'
|
||||||
|
set postponed='+Drafts'
|
||||||
|
set realname='H. M. Test'
|
||||||
|
set record='+Sent'
|
||||||
|
set spoolfile='+Inbox'
|
||||||
|
set trash='+Trash'
|
||||||
|
|
||||||
|
|
||||||
|
# Extra configuration
|
||||||
|
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:inbox"
|
|
@ -0,0 +1,38 @@
|
||||||
|
# Generated by Home Manager.
|
||||||
|
set ssl_force_tls = yes
|
||||||
|
set certificate_file=/etc/ssl/certs/ca-certificates.crt
|
||||||
|
|
||||||
|
# GPG section
|
||||||
|
set crypt_use_gpgme = yes
|
||||||
|
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 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'
|
||||||
|
set postponed='+Drafts'
|
||||||
|
set realname='H. M. Test'
|
||||||
|
set record='+Sent'
|
||||||
|
set spoolfile='+Inbox'
|
||||||
|
set trash='+Trash'
|
||||||
|
|
||||||
|
|
||||||
|
# Extra configuration
|
||||||
|
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:inbox"
|
|
@ -0,0 +1,45 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ ../../accounts/email-test-accounts.nix ];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
accounts.email.accounts = {
|
||||||
|
"hm@example.com" = {
|
||||||
|
notmuch.enable = true;
|
||||||
|
neomutt = {
|
||||||
|
enable = true;
|
||||||
|
extraConfig = ''
|
||||||
|
color status cyan default
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
imap.port = 993;
|
||||||
|
signature = {
|
||||||
|
showSignature = "append";
|
||||||
|
command = pkgs.writeScript "signature" "echo This is my signature";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.neomutt = {
|
||||||
|
enable = true;
|
||||||
|
vimKeys = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
test.stubs.neomutt = { };
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/neomutt/neomuttrc
|
||||||
|
assertFileExists home-files/.config/neomutt/hm@example.com
|
||||||
|
assertFileContent home-files/.config/neomutt/neomuttrc ${
|
||||||
|
./neomutt-expected.conf
|
||||||
|
}
|
||||||
|
expectedSignature=$(normalizeStorePaths "home-files/.config/neomutt/hm@example.com")
|
||||||
|
assertFileContent "$expectedSignature" ${
|
||||||
|
./hm-example.com-signature-command-expected
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
48
tests/modules/programs/neomutt/neomutt-with-signature.nix
Normal file
48
tests/modules/programs/neomutt/neomutt-with-signature.nix
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ ../../accounts/email-test-accounts.nix ];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
accounts.email.accounts = {
|
||||||
|
"hm@example.com" = {
|
||||||
|
notmuch.enable = true;
|
||||||
|
neomutt = {
|
||||||
|
enable = true;
|
||||||
|
extraConfig = ''
|
||||||
|
color status cyan default
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
imap.port = 993;
|
||||||
|
signature = {
|
||||||
|
showSignature = "append";
|
||||||
|
text = ''
|
||||||
|
--
|
||||||
|
Test Signature
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.neomutt = {
|
||||||
|
enable = true;
|
||||||
|
vimKeys = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
test.stubs.neomutt = { };
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/neomutt/neomuttrc
|
||||||
|
assertFileExists home-files/.config/neomutt/hm@example.com
|
||||||
|
assertFileContent home-files/.config/neomutt/neomuttrc ${
|
||||||
|
./neomutt-expected.conf
|
||||||
|
}
|
||||||
|
expectedSignature=$(normalizeStorePaths "home-files/.config/neomutt/hm@example.com")
|
||||||
|
assertFileContent "$expectedSignature" ${
|
||||||
|
./hm-example.com-signature-expected
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue