1 { config, lib, pkgs, ... }:
6 cfg = config.services.mailhog;
8 args = lib.concatStringsSep " " (
10 "-api-bind-addr :${toString cfg.apiPort}"
11 "-smtp-bind-addr :${toString cfg.smtpPort}"
12 "-ui-bind-addr :${toString cfg.uiPort}"
13 "-storage ${cfg.storage}"
14 ] ++ lib.optional (cfg.storage == "maildir")
15 "-maildir-path $STATE_DIRECTORY"
24 (mkRemovedOptionModule [ "services" "mailhog" "user" ] "")
30 enable = mkEnableOption (lib.mdDoc "MailHog");
33 type = types.enum [ "maildir" "memory" ];
35 description = lib.mdDoc "Store mails on disk or in memory.";
41 description = lib.mdDoc "Port on which the API endpoint will listen.";
47 description = lib.mdDoc "Port on which the SMTP endpoint will listen.";
53 description = lib.mdDoc "Port on which the HTTP UI will listen.";
56 extraArgs = mkOption {
57 type = types.listOf types.str;
59 description = lib.mdDoc "List of additional arguments to pass to the MailHog process.";
67 config = mkIf cfg.enable {
69 systemd.services.mailhog = {
70 description = "MailHog - Web and API based SMTP testing";
71 after = [ "network.target" ];
72 wantedBy = [ "multi-user.target" ];
75 ExecStart = "${pkgs.mailhog}/bin/MailHog ${args}";
77 Restart = "on-failure";
78 StateDirectory = "mailhog";