Compare commits

...

2 commits

2 changed files with 26 additions and 24 deletions

View file

@ -4,32 +4,38 @@
}: }:
nixosTest { nixosTest {
nodes = { nodes = {
# Host with just the default configuration
defaults = {
imports = [self.nixosModules.default];
services.tlaternet-webserver.enable = true;
};
host = { host = {
config,
lib,
pkgs,
...
}: {
imports = [self.nixosModules.default]; imports = [self.nixosModules.default];
services.tlaternet-webserver = { services.tlaternet-webserver = {
enable = true; enable = true;
listen = { listen = {
addr = "0.0.0.0"; addr = "0.0.0.0";
port = 8000; port = 8080;
}; };
}; };
networking.firewall.allowedTCPPorts = [8000]; networking.firewall.allowedTCPPorts = [8080];
}; };
client = {pkgs, ...}: {}; client = {};
}; };
testScript = '' testScript = ''
start_all() start_all()
host.wait_for_unit("default.target") # Assert that the defaults work
client.succeed("curl --fail http://host:8000/ >&2") defaults.wait_for_unit("tlaternet-webserver.service")
defaults.succeed("curl --fail http://localhost:8000 >&2")
# Assert that we can listen on a public interface
host.wait_for_unit("tlaternet-webserver.service")
client.succeed("curl --fail http://host:8080 >&2")
''; '';
} }

View file

@ -16,21 +16,17 @@ in {
options = { options = {
services.tlaternet-webserver = { services.tlaternet-webserver = {
enable = mkEnableOption "tlaternet web server"; enable = mkEnableOption "tlaternet web server";
listen = mkOption { listen = {
type = submodule { addr = mkOption {
options = { type = str;
addr = mkOption { description = "IP address.";
type = str; default = "127.0.0.1";
description = "IP address."; };
default = "127.0.0.1";
};
port = mkOption { port = mkOption {
type = int; type = int;
description = "Port number."; description = "Port number.";
default = 8000; default = 8000;
};
};
}; };
}; };
}; };