Merge pull request #83768 from mmahut/magic-wormhole-mailbox-server

nixos/magic-wormhole-mailbox-server: init
This commit is contained in:
Marek Mahut 2020-03-31 15:01:38 +02:00 committed by GitHub
commit 63f3adfc3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 68 additions and 0 deletions

View file

@ -394,6 +394,7 @@
./services/mail/mailcatcher.nix
./services/mail/mailhog.nix
./services/mail/mailman.nix
./services/mail/magic-wormhole-mailbox-server.nix
./services/mail/mlmmj.nix
./services/mail/offlineimap.nix
./services/mail/opendkim.nix

View file

@ -0,0 +1,28 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.magic-wormhole-mailbox-server;
dataDir = "/var/lib/magic-wormhole-mailbox-server;";
python = pkgs.python3.withPackages (py: [ py.magic-wormhole-mailbox-server py.twisted ]);
in
{
options.services.magic-wormhole-mailbox-server = {
enable = mkEnableOption "Enable Magic Wormhole Mailbox Server";
};
config = mkIf cfg.enable {
systemd.services.magic-wormhole-mailbox-server = {
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
DynamicUser = true;
ExecStart = "${python}/bin/twistd --nodaemon wormhole-mailbox";
WorkingDirectory = dataDir;
StateDirectory = baseNameOf dataDir;
};
};
};
}

View file

@ -170,6 +170,7 @@ in
#logstash = handleTest ./logstash.nix {};
lorri = handleTest ./lorri/default.nix {};
magnetico = handleTest ./magnetico.nix {};
magic-wormhole-mailbox-server = handleTest ./magic-wormhole-mailbox-server.nix {};
mailcatcher = handleTest ./mailcatcher.nix {};
mathics = handleTest ./mathics.nix {};
matomo = handleTest ./matomo.nix {};

View file

@ -0,0 +1,38 @@
import ./make-test-python.nix ({ pkgs, ... }: {
name = "magic-wormhole-mailbox-server";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ mmahut ];
};
nodes = {
server = { ... }: {
networking.firewall.allowedTCPPorts = [ 4000 ];
services.magic-wormhole-mailbox-server.enable = true;
};
client_alice = { ... }: {
networking.firewall.enable = false;
environment.systemPackages = [ pkgs.magic-wormhole ];
};
client_bob = { ... }: {
environment.systemPackages = [ pkgs.magic-wormhole ];
};
};
testScript = ''
start_all()
# Start the wormhole relay server
server.wait_for_unit("magic-wormhole-mailbox-server.service")
server.wait_for_open_port(4000)
# Create a secret file and send it to Bob
client_alice.succeed("echo mysecret > secretfile")
client_alice.succeed("wormhole --relay-url=ws://server:4000/v1 send -0 secretfile &")
# Retrieve a secret file from Alice and check its content
client_bob.succeed("wormhole --relay-url=ws://server:4000/v1 receive -0 --accept-file")
client_bob.succeed("grep mysecret secretfile")
'';
})