about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAaron Andersen <aaron@fosslib.net>2019-03-26 20:56:24 -0400
committerAaron Andersen <aaron@fosslib.net>2019-03-27 09:15:47 -0400
commit395ec8c0d4e179d185a18a1d785bd708133928e2 (patch)
tree5ce62a65b8003941c3118fb05f5c649d16e8938d
parent2dc4153633f2184f5612446b3a2ba7f999cfe5fe (diff)
downloadnixlib-395ec8c0d4e179d185a18a1d785bd708133928e2.tar
nixlib-395ec8c0d4e179d185a18a1d785bd708133928e2.tar.gz
nixlib-395ec8c0d4e179d185a18a1d785bd708133928e2.tar.bz2
nixlib-395ec8c0d4e179d185a18a1d785bd708133928e2.tar.lz
nixlib-395ec8c0d4e179d185a18a1d785bd708133928e2.tar.xz
nixlib-395ec8c0d4e179d185a18a1d785bd708133928e2.tar.zst
nixlib-395ec8c0d4e179d185a18a1d785bd708133928e2.zip
nixos/mailcatcher: init module for existing package
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/mail/mailcatcher.nix60
2 files changed, 61 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index dc571602581b..fad7f336c995 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -349,6 +349,7 @@
   ./services/mail/exim.nix
   ./services/mail/freepops.nix
   ./services/mail/mail.nix
+  ./services/mail/mailcatcher.nix
   ./services/mail/mailhog.nix
   ./services/mail/mlmmj.nix
   ./services/mail/offlineimap.nix
diff --git a/nixos/modules/services/mail/mailcatcher.nix b/nixos/modules/services/mail/mailcatcher.nix
new file mode 100644
index 000000000000..2c6aadadce9d
--- /dev/null
+++ b/nixos/modules/services/mail/mailcatcher.nix
@@ -0,0 +1,60 @@
+{ config, pkgs, lib, ... }:
+
+let
+  cfg = config.services.mailcatcher;
+
+  inherit (lib) mkEnableOption mkIf mkOption types;
+in
+{
+  # interface
+
+  options = {
+
+    services.mailcatcher = {
+      enable = mkEnableOption "Enable 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}";
+      };
+    };
+  };
+}