about summary refs log tree commit diff
path: root/modules/thelounge.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/thelounge.nix')
-rw-r--r--modules/thelounge.nix49
1 files changed, 49 insertions, 0 deletions
diff --git a/modules/thelounge.nix b/modules/thelounge.nix
new file mode 100644
index 0000000..ae4b4ff
--- /dev/null
+++ b/modules/thelounge.nix
@@ -0,0 +1,49 @@
+{
+  config,
+  lib,
+  libNginx,
+  ...
+}:
+let
+  cfg = config.nixfiles.modules.thelounge;
+in
+{
+  options.nixfiles.modules.thelounge = {
+    enable = lib.mkEnableOption "The Lounge";
+
+    port = lib.mkOption {
+      description = "Port.";
+      type = lib.types.port;
+      default = 11887;
+    };
+
+    domain = lib.mkOption {
+      description = "Domain name sans protocol scheme.";
+      type = lib.types.str;
+      default = "irc.${config.networking.domain}";
+    };
+  };
+
+  config = lib.mkIf cfg.enable {
+    ark.directories = [ "/var/lib/thelounge" ];
+
+    nixfiles.modules.nginx = {
+      upstreams.thelounge.servers."127.0.0.1:${toString cfg.port}" = { };
+      virtualHosts.${cfg.domain} = {
+        locations."/".proxyPass = "http://thelounge";
+        extraConfig = libNginx.config.internalOnly;
+      };
+    };
+
+    services.thelounge = {
+      enable = true;
+      extraConfig = {
+        public = false;
+        host = "127.0.0.1";
+        inherit (cfg) port;
+        reverseProxy = true;
+        defaults = { };
+      };
+    };
+  };
+}

Consider giving Nix/NixOS a try! <3