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;
|
||||
name = "Rene Treffer";
|
||||
};
|
||||
RTUnreal = {
|
||||
email = "unreal+nixpkgs@rtinf.net";
|
||||
github = "RTUnreal";
|
||||
githubId = 22859658;
|
||||
name = "RTUnreal";
|
||||
};
|
||||
rubenhoenle = {
|
||||
email = "git@hoenle.xyz";
|
||||
github = "rubenhoenle";
|
||||
|
@ -1,4 +1,9 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.services.mailhog;
|
||||
|
||||
@ -8,17 +13,24 @@ let
|
||||
"-smtp-bind-addr :${toString cfg.smtpPort}"
|
||||
"-ui-bind-addr :${toString cfg.uiPort}"
|
||||
"-storage ${cfg.storage}"
|
||||
] ++ lib.optional (cfg.storage == "maildir")
|
||||
"-maildir-path $STATE_DIRECTORY"
|
||||
]
|
||||
++ lib.optional (cfg.storage == "maildir") "-maildir-path $STATE_DIRECTORY"
|
||||
++ cfg.extraArgs
|
||||
);
|
||||
|
||||
mhsendmail = pkgs.writeShellScriptBin "mailhog-sendmail" ''
|
||||
exec ${lib.getExe pkgs.mailhog} sendmail $@
|
||||
'';
|
||||
in
|
||||
{
|
||||
###### interface
|
||||
|
||||
imports = [
|
||||
(lib.mkRemovedOptionModule [ "services" "mailhog" "user" ] "")
|
||||
(lib.mkRemovedOptionModule [
|
||||
"services"
|
||||
"mailhog"
|
||||
"user"
|
||||
] "")
|
||||
];
|
||||
|
||||
options = {
|
||||
@ -26,8 +38,15 @@ in
|
||||
services.mailhog = {
|
||||
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 {
|
||||
type = lib.types.enum [ "maildir" "memory" ];
|
||||
type = lib.types.enum [
|
||||
"maildir"
|
||||
"memory"
|
||||
];
|
||||
default = "memory";
|
||||
description = "Store mails on disk or in memory.";
|
||||
};
|
||||
@ -52,13 +71,12 @@ in
|
||||
|
||||
extraArgs = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [];
|
||||
default = [ ];
|
||||
description = "List of additional arguments to pass to the MailHog process.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
###### implementation
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
@ -69,11 +87,21 @@ in
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "exec";
|
||||
ExecStart = "${pkgs.mailhog}/bin/MailHog ${args}";
|
||||
ExecStart = "${lib.getExe pkgs.mailhog} ${args}";
|
||||
DynamicUser = true;
|
||||
Restart = "on-failure";
|
||||
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