Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7abf9be865ec
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3fc3096da84d
Choose a head ref
  • 3 commits
  • 4 files changed
  • 2 contributors

Commits on Mar 27, 2019

  1. Copy the full SHA
    395ec8c View commit details
  2. Copy the full SHA
    c99ea1c View commit details
  3. Merge pull request #58432 from aanderse/mailcatcher

    nixos/mailcatcher: init module for existing package
    Ma27 authored Mar 27, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3fc3096 View commit details
Showing with 88 additions and 0 deletions.
  1. +1 −0 nixos/modules/module-list.nix
  2. +60 −0 nixos/modules/services/mail/mailcatcher.nix
  3. +1 −0 nixos/tests/all-tests.nix
  4. +26 −0 nixos/tests/mailcatcher.nix
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
@@ -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
60 changes: 60 additions & 0 deletions nixos/modules/services/mail/mailcatcher.nix
Original file line number Diff line number Diff line change
@@ -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}";
};
};
};
}
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
@@ -131,6 +131,7 @@ in
#lightdm = handleTest ./lightdm.nix {};
login = handleTest ./login.nix {};
#logstash = handleTest ./logstash.nix {};
mailcatcher = handleTest ./mailcatcher.nix {};
mathics = handleTest ./mathics.nix {};
matrix-synapse = handleTest ./matrix-synapse.nix {};
memcached = handleTest ./memcached.nix {};
26 changes: 26 additions & 0 deletions nixos/tests/mailcatcher.nix
Original file line number Diff line number Diff line change
@@ -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;
'';
})