1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.mailhog;
7in {
8 ###### interface
9
10 options = {
11
12 services.mailhog = {
13 enable = mkEnableOption "MailHog";
14 user = mkOption {
15 type = types.str;
16 default = "mailhog";
17 description = "User account under which mailhog runs.";
18 };
19 };
20 };
21
22
23 ###### implementation
24
25 config = mkIf cfg.enable {
26
27 users.extraUsers.mailhog = {
28 name = cfg.user;
29 description = "MailHog service user";
30 };
31
32 systemd.services.mailhog = {
33 description = "MailHog service";
34 after = [ "network.target" ];
35 wantedBy = [ "multi-user.target" ];
36 serviceConfig = {
37 Type = "simple";
38 ExecStart = "${pkgs.mailhog}/bin/MailHog";
39 User = cfg.user;
40 };
41 };
42 };
43}