Merge pull request #58432 from aanderse/mailcatcher

nixos/mailcatcher: init module for existing package
This commit is contained in:
Maximilian Bosch 2019-03-27 16:11:15 +01:00 committed by GitHub
commit 3fc3096da8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 88 additions and 0 deletions

View File

@ -349,6 +349,7 @@
./services/mail/exim.nix ./services/mail/exim.nix
./services/mail/freepops.nix ./services/mail/freepops.nix
./services/mail/mail.nix ./services/mail/mail.nix
./services/mail/mailcatcher.nix
./services/mail/mailhog.nix ./services/mail/mailhog.nix
./services/mail/mlmmj.nix ./services/mail/mlmmj.nix
./services/mail/offlineimap.nix ./services/mail/offlineimap.nix

View File

@ -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}";
};
};
};
}

View File

@ -131,6 +131,7 @@ in
#lightdm = handleTest ./lightdm.nix {}; #lightdm = handleTest ./lightdm.nix {};
login = handleTest ./login.nix {}; login = handleTest ./login.nix {};
#logstash = handleTest ./logstash.nix {}; #logstash = handleTest ./logstash.nix {};
mailcatcher = handleTest ./mailcatcher.nix {};
mathics = handleTest ./mathics.nix {}; mathics = handleTest ./mathics.nix {};
matrix-synapse = handleTest ./matrix-synapse.nix {}; matrix-synapse = handleTest ./matrix-synapse.nix {};
memcached = handleTest ./memcached.nix {}; memcached = handleTest ./memcached.nix {};

View File

@ -0,0 +1,26 @@
import ./make-test.nix ({ lib, ... }:
{
name = "mailcatcher";
meta.maintainers = [ lib.maintainers.aanderse ];
machine =
{ pkgs, ... }:
{
services.mailcatcher.enable = true;
networking.defaultMailServer.directDelivery = true;
networking.defaultMailServer.hostName = "localhost:1025";
environment.systemPackages = [ pkgs.mailutils ];
};
testScript = ''
startAll;
$machine->waitForUnit('mailcatcher.service');
$machine->waitForOpenPort('1025');
$machine->succeed('echo "this is the body of the email" | mail -s "subject" root@example.org');
$machine->succeed('curl http://localhost:1080/messages/1.json') =~ /this is the body of the email/ or die;
'';
})