aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/modules/services/mail/mailcatcher.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/services/mail/mailcatcher.nix')
-rw-r--r--nixpkgs/nixos/modules/services/mail/mailcatcher.nix61
1 files changed, 61 insertions, 0 deletions
diff --git a/nixpkgs/nixos/modules/services/mail/mailcatcher.nix b/nixpkgs/nixos/modules/services/mail/mailcatcher.nix
new file mode 100644
index 00000000000..f5b4508b335
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/mail/mailcatcher.nix
@@ -0,0 +1,61 @@
+{ config, pkgs, lib, ... }:
+
+let
+ cfg = config.services.mailcatcher;
+
+ inherit (lib) mkEnableOption mkIf mkOption types optionalString;
+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}";
+ AmbientCapabilities = optionalString (cfg.http.port < 1024 || cfg.smtp.port < 1024) "cap_net_bind_service";
+ };
+ };
+ };
+}