From 9aa9ef973fb020fe5e4cc23a320ff2ed5989fb72 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Schr=C3=B6ter?= <dev@felschr.com>
Date: Fri, 29 Sep 2023 22:45:34 +0200
Subject: [PATCH] chore: move collabora-office to own file

---
 hosts/home-server.nix         |  1 +
 services/collabora-office.nix | 35 +++++++++++++++++++++++++++++++++++
 services/nextcloud.nix        | 33 ---------------------------------
 3 files changed, 36 insertions(+), 33 deletions(-)
 create mode 100644 services/collabora-office.nix

diff --git a/hosts/home-server.nix b/hosts/home-server.nix
index 00b8142..018df18 100644
--- a/hosts/home-server.nix
+++ b/hosts/home-server.nix
@@ -31,6 +31,7 @@ in with builtins; {
     ../services/miniflux.nix
     ../services/paperless.nix
     ../services/nextcloud.nix
+    ../services/collabora-office.nix
     ../services/calibre-web.nix
     ../services/focalboard.nix
   ];
diff --git a/services/collabora-office.nix b/services/collabora-office.nix
new file mode 100644
index 0000000..b2d5117
--- /dev/null
+++ b/services/collabora-office.nix
@@ -0,0 +1,35 @@
+_:
+
+{
+  virtualisation.oci-containers.containers.collabora-office = {
+    image = "docker.io/collabora/code";
+    ports = [ "9980:9980" ];
+    environment = let
+      mkAlias = domain:
+        "https://" + (builtins.replaceStrings [ "." ] [ "\\." ] domain)
+        + ":443";
+    in {
+      server_name = "office.felschr.com";
+      aliasgroup1 = mkAlias "office.felschr.com";
+      aliasgroup2 = mkAlias "cloud.felschr.com";
+      extra_params = "--o:ssl.enable=false --o:ssl.termination=true";
+    };
+    extraOptions = [
+      "--network=host"
+      "--cap-add=MKNOD"
+      "--label=io.containers.autoupdate=registry"
+    ];
+  };
+
+  services.nginx.virtualHosts."office.felschr.com" = {
+    forceSSL = true;
+    enableACME = true;
+    locations."/" = {
+      proxyPass = "http://127.0.0.1:9980";
+      proxyWebsockets = true;
+      extraConfig = ''
+        proxy_read_timeout 36000s;
+      '';
+    };
+  };
+}
diff --git a/services/nextcloud.nix b/services/nextcloud.nix
index f62849b..1778c80 100644
--- a/services/nextcloud.nix
+++ b/services/nextcloud.nix
@@ -37,39 +37,6 @@ in {
     }];
   };
 
-  # Office
-  # TODO move to own config
-  virtualisation.oci-containers.containers.collabora-office = {
-    image = "docker.io/collabora/code";
-    ports = [ "9980:9980" ];
-    environment = let
-      mkAlias = domain:
-        "https://" + (builtins.replaceStrings [ "." ] [ "\\." ] domain)
-        + ":443";
-    in {
-      server_name = "office.felschr.com";
-      aliasgroup1 = mkAlias "office.felschr.com";
-      aliasgroup2 = mkAlias "cloud.felschr.com";
-      extra_params = "--o:ssl.enable=false --o:ssl.termination=true";
-    };
-    extraOptions = [
-      "--network=host"
-      "--cap-add=MKNOD"
-      "--label=io.containers.autoupdate=registry"
-    ];
-  };
-  services.nginx.virtualHosts."office.felschr.com" = {
-    forceSSL = true;
-    enableACME = true;
-    locations."/" = {
-      proxyPass = "http://127.0.0.1:9980";
-      proxyWebsockets = true;
-      extraConfig = ''
-        proxy_read_timeout 36000s;
-      '';
-    };
-  };
-
   # ensure that postgres is running *before* running the setup
   systemd.services."nextcloud-setup" = {
     requires = [ "postgresql.service" ];