mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-01 06:31:04 +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}
|
from ${alias}
|
||||||
'') aliases
|
'') aliases
|
||||||
);
|
);
|
||||||
|
|
||||||
configFile = mailAccounts: ''
|
|
||||||
# Generated by Home Manager.
|
|
||||||
|
|
||||||
${cfg.extraConfig}
|
|
||||||
|
|
||||||
${lib.concatStringsSep "\n\n" (map accountStr mailAccounts)}
|
|
||||||
|
|
||||||
${cfg.extraAccounts}
|
|
||||||
'';
|
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -66,9 +55,36 @@ in
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "msmtp" { };
|
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 {
|
extraConfig = mkOption {
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
default = "";
|
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 = ''
|
description = ''
|
||||||
Extra configuration lines to add to {file}`~/.msmtprc`.
|
Extra configuration lines to add to {file}`~/.msmtprc`.
|
||||||
See <https://marlam.de/msmtp/msmtprc.txt> for examples.
|
See <https://marlam.de/msmtp/msmtprc.txt> for examples.
|
||||||
|
|
@ -83,6 +99,14 @@ in
|
||||||
extraAccounts = mkOption {
|
extraAccounts = mkOption {
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
default = "";
|
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 = ''
|
description = ''
|
||||||
Extra configuration lines to add to the end of {file}`~/.msmtprc`.
|
Extra configuration lines to add to the end of {file}`~/.msmtprc`.
|
||||||
See <https://marlam.de/msmtp/msmtprc.txt> for examples.
|
See <https://marlam.de/msmtp/msmtprc.txt> for examples.
|
||||||
|
|
@ -95,14 +119,25 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable (
|
||||||
home.packages = [ cfg.package ];
|
lib.mkMerge [
|
||||||
|
{
|
||||||
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
xdg.configFile."msmtp/config".text = configFile msmtpAccounts;
|
xdg.configFile."msmtp/config".text = cfg.configContent;
|
||||||
|
|
||||||
home.sessionVariables = {
|
programs.msmtp.configContent = lib.mkMerge [
|
||||||
MSMTPQ_Q = "${config.xdg.dataHome}/msmtp/queue";
|
(lib.mkBefore "# Generated by Home Manager.")
|
||||||
MSMTPQ_LOG = "${config.xdg.dataHome}/msmtp/queue.log";
|
(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