mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-12 03:56:17 +03:00
4a11ce7f26
Closes #59911
61 lines
1.4 KiB
Nix
61 lines
1.4 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
cfg = config.services.mailcatcher;
|
|
|
|
inherit (lib) mkEnableOption mkIf mkOption types;
|
|
in
|
|
{
|
|
# interface
|
|
|
|
options = {
|
|
|
|
services.mailcatcher = {
|
|
enable = mkEnableOption "MailCatcher";
|
|
|
|
http.ip = mkOption {
|
|
type = types.str;
|
|
default = "127.0.0.1";
|
|
description = "The ip address of the http server.";
|
|
};
|
|
|
|
http.port = mkOption {
|
|
type = types.port;
|
|
default = 1080;
|
|
description = "The port address of the http server.";
|
|
};
|
|
|
|
smtp.ip = mkOption {
|
|
type = types.str;
|
|
default = "127.0.0.1";
|
|
description = "The ip address of the smtp server.";
|
|
};
|
|
|
|
smtp.port = mkOption {
|
|
type = types.port;
|
|
default = 1025;
|
|
description = "The port address of the smtp server.";
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
# implementation
|
|
|
|
config = mkIf cfg.enable {
|
|
environment.systemPackages = [ pkgs.mailcatcher ];
|
|
|
|
systemd.services.mailcatcher = {
|
|
description = "MailCatcher Service";
|
|
after = [ "network.target" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
DynamicUser = true;
|
|
Restart = "always";
|
|
ExecStart = "${pkgs.mailcatcher}/bin/mailcatcher --foreground --no-quit --http-ip ${cfg.http.ip} --http-port ${toString cfg.http.port} --smtp-ip ${cfg.smtp.ip} --smtp-port ${toString cfg.smtp.port}";
|
|
};
|
|
};
|
|
};
|
|
}
|