From 4c9e93f50821b88280733ae47d634ca1c01391a4 Mon Sep 17 00:00:00 2001
From: Julien Malka <julien.malka@me.com>
Date: Fri, 11 Mar 2022 01:07:21 +0100
Subject: [PATCH] Added irc service

---
 machines/lisa/default.nix |  1 +
 modules/irc/default.nix   | 38 ++++++++++++++++++++------------------
 modules/nginx/default.nix |  8 ++++----
 3 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/machines/lisa/default.nix b/machines/lisa/default.nix
index 5a56d67..f92f4ab 100644
--- a/machines/lisa/default.nix
+++ b/machines/lisa/default.nix
@@ -11,6 +11,7 @@
 
 
   luj = {
+    irc.enable = true;
     mediaserver = {
       enable = true;
       tv.enable = true;
diff --git a/modules/irc/default.nix b/modules/irc/default.nix
index 9e8ca76..33d110d 100644
--- a/modules/irc/default.nix
+++ b/modules/irc/default.nix
@@ -2,30 +2,32 @@
 with lib;
 let
   cfg = config.luj.irc;
-  port = 9117;
+  port = 2042;
 in
 {
 
   options.luj.irc = {
     enable = mkEnableOption "activate weechat service";
-    nginx.enable = mkEnableOption "activate nginx";
-    nginx.subdomain = mkOption {
-      type = types.str;
+  };
+
+  config = mkIf cfg.enable {
+
+    services.weechat.enable = true;
+    services.nginx.virtualHosts."irc.julienmalka.me" = {
+      forceSSL = true;
+      enableACME = true;
+      locations."^~ /weechat" = {
+        proxyPass = "http://127.0.0.1:${builtins.toString port}";
+        proxyWebsockets = true;
+      };
+      locations."/" = {
+        root = pkgs.glowing-bear;
+      };
     };
 
   };
-
-  config = mkIf cfg.enable (
-    mkMerge [{
-    services.weechat.enable = true; 
-    }
-
-      (mkIf cfg.nginx.enable (mkPrivateSubdomain cfg.nginx.subdomain port))
-
-      
-      (mkIf cfg.nginx.enable (mkVPNSubdomain cfg.nginx.subdomain port))]);
- 
-
-
-
 }
+    
+
+
+
diff --git a/modules/nginx/default.nix b/modules/nginx/default.nix
index b7c9d4e..540eafb 100644
--- a/modules/nginx/default.nix
+++ b/modules/nginx/default.nix
@@ -21,11 +21,11 @@ in
 
     services.nginx = {
       enable = true;
-      recommendedOptimisation = true;
-      recommendedTlsSettings = true;
-      recommendedProxySettings = true;
-      clientMaxBodySize = "128m";
 
+      recommendedGzipSettings = true;
+    recommendedOptimisation = true;
+    recommendedProxySettings = true;
+    recommendedTlsSettings = true;
       commonHttpConfig = ''
         server_names_hash_bucket_size 128;
       '';