From 3155d665ff4af43e79942e93825f1c48859b78e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= <tm@tlater.net>
Date: Fri, 14 Oct 2022 12:06:33 +0100
Subject: [PATCH 1/2] checks: Add assertion that the module defaults work

---
 nix/checks/open-homepage.nix | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/nix/checks/open-homepage.nix b/nix/checks/open-homepage.nix
index dba360e..dfecde6 100644
--- a/nix/checks/open-homepage.nix
+++ b/nix/checks/open-homepage.nix
@@ -4,32 +4,38 @@
 }:
 nixosTest {
   nodes = {
+    # Host with just the default configuration
+    defaults = {
+      imports = [self.nixosModules.default];
+      services.tlaternet-webserver.enable = true;
+    };
+
     host = {
-      config,
-      lib,
-      pkgs,
-      ...
-    }: {
       imports = [self.nixosModules.default];
 
       services.tlaternet-webserver = {
         enable = true;
         listen = {
           addr = "0.0.0.0";
-          port = 8000;
+          port = 8080;
         };
       };
 
-      networking.firewall.allowedTCPPorts = [8000];
+      networking.firewall.allowedTCPPorts = [8080];
     };
 
-    client = {pkgs, ...}: {};
+    client = {};
   };
 
   testScript = ''
     start_all()
 
-    host.wait_for_unit("default.target")
-    client.succeed("curl --fail http://host:8000/ >&2")
+    # Assert that the defaults work
+    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")
   '';
 }

From 5d037f9122e68aaa5db62d04810bf0c5e1e4325e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= <tm@tlater.net>
Date: Fri, 14 Oct 2022 12:16:51 +0100
Subject: [PATCH 2/2] module: Fix broken defaults for the address to listen on

---
 nix/module.nix | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/nix/module.nix b/nix/module.nix
index 255e15c..6515c54 100644
--- a/nix/module.nix
+++ b/nix/module.nix
@@ -16,21 +16,17 @@ in {
   options = {
     services.tlaternet-webserver = {
       enable = mkEnableOption "tlaternet web server";
-      listen = mkOption {
-        type = submodule {
-          options = {
-            addr = mkOption {
-              type = str;
-              description = "IP address.";
-              default = "127.0.0.1";
-            };
+      listen = {
+        addr = mkOption {
+          type = str;
+          description = "IP address.";
+          default = "127.0.0.1";
+        };
 
-            port = mkOption {
-              type = int;
-              description = "Port number.";
-              default = 8000;
-            };
-          };
+        port = mkOption {
+          type = int;
+          description = "Port number.";
+          default = 8000;
         };
       };
     };