mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-30 22:21:02 +01:00
programs.msmtp: merge extraConfig and extraAccount into configContent (#7385)
We can simplify maintainance of HM while providing more consistency across modules by relying on the nixpkgs module primitive mkBefore / mkOrder as it was done in the Zsh module. Deprecates: - programs.msmtp.extraConfig - programs.msmtp.extraAccounts programs.msmtp: merge extraConfig and extraAccount into configContent We can simplify maintainance of HM while providing more consistency across modules by relying on the nixpkgs module primitive mkBefore / mkOrder as it was done in the Zsh module. Deprecates: - programs.msmtp.extraConfig - programs.msmtp.extraAccounts
This commit is contained in:
parent
36c57c6a1d
commit
d75a547415
1 changed files with 54 additions and 19 deletions
|
|
@ -46,17 +46,6 @@ let
|
|||
from ${alias}
|
||||
'') aliases
|
||||
);
|
||||
|
||||
configFile = mailAccounts: ''
|
||||
# Generated by Home Manager.
|
||||
|
||||
${cfg.extraConfig}
|
||||
|
||||
${lib.concatStringsSep "\n\n" (map accountStr mailAccounts)}
|
||||
|
||||
${cfg.extraAccounts}
|
||||
'';
|
||||
|
||||
in
|
||||
{
|
||||
|
||||
|
|
@ -66,9 +55,36 @@ in
|
|||
|
||||
package = lib.mkPackageOption pkgs "msmtp" { };
|
||||
|
||||
configContent = mkOption {
|
||||
default = "";
|
||||
type = types.lines;
|
||||
example = lib.literalExpression ''
|
||||
lib.mkOrder 1200 ''''
|
||||
set syslog
|
||||
'''';
|
||||
'';
|
||||
description = ''
|
||||
Content added to msmtp config.
|
||||
See <https://marlam.de/msmtp/msmtprc.txt> for examples.
|
||||
|
||||
Note, if running msmtp fails with the error message "account default
|
||||
was already defined" then you probably have an account command here.
|
||||
Account commands should be placed in
|
||||
[](#opt-accounts.email.accounts._name_.msmtp.extraConfig).
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
visible = false;
|
||||
apply =
|
||||
x:
|
||||
lib.warnIfNot (x == "") ''
|
||||
`programs.msmtp.extraConfig` is deprecated, use `programs.msmtp.configContent` instead.
|
||||
|
||||
Example: programs.msmtp.configContent = lib.mkBefore "set syslog";
|
||||
'' x;
|
||||
description = ''
|
||||
Extra configuration lines to add to {file}`~/.msmtprc`.
|
||||
See <https://marlam.de/msmtp/msmtprc.txt> for examples.
|
||||
|
|
@ -83,6 +99,14 @@ in
|
|||
extraAccounts = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
visible = false;
|
||||
apply =
|
||||
x:
|
||||
lib.warnIfNot (x == "") ''
|
||||
`programs.msmtp.extraAccounts` is deprecated, use `programs.msmtp.configContent` instead.
|
||||
|
||||
Example: programs.msmtp.configContent = lib.mkAfter "set syslog";
|
||||
'' x;
|
||||
description = ''
|
||||
Extra configuration lines to add to the end of {file}`~/.msmtprc`.
|
||||
See <https://marlam.de/msmtp/msmtprc.txt> for examples.
|
||||
|
|
@ -95,14 +119,25 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
config = lib.mkIf cfg.enable (
|
||||
lib.mkMerge [
|
||||
{
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
xdg.configFile."msmtp/config".text = configFile msmtpAccounts;
|
||||
xdg.configFile."msmtp/config".text = cfg.configContent;
|
||||
|
||||
home.sessionVariables = {
|
||||
MSMTPQ_Q = "${config.xdg.dataHome}/msmtp/queue";
|
||||
MSMTPQ_LOG = "${config.xdg.dataHome}/msmtp/queue.log";
|
||||
};
|
||||
};
|
||||
programs.msmtp.configContent = lib.mkMerge [
|
||||
(lib.mkBefore "# Generated by Home Manager.")
|
||||
(lib.mkIf (cfg.extraConfig != "") (lib.mkBefore cfg.extraConfig))
|
||||
(lib.concatStringsSep "\n\n" (map accountStr msmtpAccounts))
|
||||
(lib.mkIf (cfg.extraAccounts != "") (lib.mkAfter cfg.extraAccounts))
|
||||
];
|
||||
|
||||
home.sessionVariables = {
|
||||
MSMTPQ_Q = "${config.xdg.dataHome}/msmtp/queue";
|
||||
MSMTPQ_LOG = "${config.xdg.dataHome}/msmtp/queue.log";
|
||||
};
|
||||
}
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue