nixos/mailhog: add setSendmail option for sendmail setuid wrapper.
This might be used in dev environments, where `sendmail` is the prefered mail transport.
This commit is contained in:
parent
bacf4b51e3
commit
5e83e20cb7
@ -18077,6 +18077,12 @@
|
|||||||
githubId = 61306;
|
githubId = 61306;
|
||||||
name = "Rene Treffer";
|
name = "Rene Treffer";
|
||||||
};
|
};
|
||||||
|
RTUnreal = {
|
||||||
|
email = "unreal+nixpkgs@rtinf.net";
|
||||||
|
github = "RTUnreal";
|
||||||
|
githubId = 22859658;
|
||||||
|
name = "RTUnreal";
|
||||||
|
};
|
||||||
rubenhoenle = {
|
rubenhoenle = {
|
||||||
email = "git@hoenle.xyz";
|
email = "git@hoenle.xyz";
|
||||||
github = "rubenhoenle";
|
github = "rubenhoenle";
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.services.mailhog;
|
cfg = config.services.mailhog;
|
||||||
|
|
||||||
@ -8,17 +13,24 @@ let
|
|||||||
"-smtp-bind-addr :${toString cfg.smtpPort}"
|
"-smtp-bind-addr :${toString cfg.smtpPort}"
|
||||||
"-ui-bind-addr :${toString cfg.uiPort}"
|
"-ui-bind-addr :${toString cfg.uiPort}"
|
||||||
"-storage ${cfg.storage}"
|
"-storage ${cfg.storage}"
|
||||||
] ++ lib.optional (cfg.storage == "maildir")
|
]
|
||||||
"-maildir-path $STATE_DIRECTORY"
|
++ lib.optional (cfg.storage == "maildir") "-maildir-path $STATE_DIRECTORY"
|
||||||
++ cfg.extraArgs
|
++ cfg.extraArgs
|
||||||
);
|
);
|
||||||
|
|
||||||
|
mhsendmail = pkgs.writeShellScriptBin "mailhog-sendmail" ''
|
||||||
|
exec ${lib.getExe pkgs.mailhog} sendmail $@
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
###### interface
|
###### interface
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
(lib.mkRemovedOptionModule [ "services" "mailhog" "user" ] "")
|
(lib.mkRemovedOptionModule [
|
||||||
|
"services"
|
||||||
|
"mailhog"
|
||||||
|
"user"
|
||||||
|
] "")
|
||||||
];
|
];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
@ -26,8 +38,15 @@ in
|
|||||||
services.mailhog = {
|
services.mailhog = {
|
||||||
enable = lib.mkEnableOption "MailHog, web and API based SMTP testing";
|
enable = lib.mkEnableOption "MailHog, web and API based SMTP testing";
|
||||||
|
|
||||||
|
setSendmail = lib.mkEnableOption "set the system sendmail to mailhogs's" // {
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
|
||||||
storage = lib.mkOption {
|
storage = lib.mkOption {
|
||||||
type = lib.types.enum [ "maildir" "memory" ];
|
type = lib.types.enum [
|
||||||
|
"maildir"
|
||||||
|
"memory"
|
||||||
|
];
|
||||||
default = "memory";
|
default = "memory";
|
||||||
description = "Store mails on disk or in memory.";
|
description = "Store mails on disk or in memory.";
|
||||||
};
|
};
|
||||||
@ -52,13 +71,12 @@ in
|
|||||||
|
|
||||||
extraArgs = lib.mkOption {
|
extraArgs = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = [];
|
default = [ ];
|
||||||
description = "List of additional arguments to pass to the MailHog process.";
|
description = "List of additional arguments to pass to the MailHog process.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
@ -69,11 +87,21 @@ in
|
|||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "exec";
|
Type = "exec";
|
||||||
ExecStart = "${pkgs.mailhog}/bin/MailHog ${args}";
|
ExecStart = "${lib.getExe pkgs.mailhog} ${args}";
|
||||||
DynamicUser = true;
|
DynamicUser = true;
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
StateDirectory = "mailhog";
|
StateDirectory = "mailhog";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.mail.sendmailSetuidWrapper = lib.mkIf cfg.setSendmail {
|
||||||
|
program = "sendmail";
|
||||||
|
source = lib.getExe mhsendmail;
|
||||||
|
# Communication happens through the network, no data is written to disk
|
||||||
|
owner = "nobody";
|
||||||
|
group = "nogroup";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
meta.maintainers = with lib.maintainers; [RTUnreal];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user