Add calibre and remove dead kavita guts

Calibre and Kavita are both services to read books, we are switching
away from Kavita due to its non-support of single-sign-on

Calibre only supports arbitrary single-sign-on via a header, but we can
use oauth2-proxy to connect it with keycloak anyway. This will be done
in a followup change

Change-Id: I3cb5940d86095299d3e8d3e8cfb94470daf48db4
Reviewed-on: https://git.clicks.codes/c/Clicks/NixFiles/+/202
Tested-by: Skyler Grey <minion@clicks.codes>
Reviewed-by: Samuel Shuert <coded@clicks.codes>
diff --git a/modules/common/calibre.nix b/modules/common/calibre.nix
new file mode 100644
index 0000000..c11d0a8
--- /dev/null
+++ b/modules/common/calibre.nix
@@ -0,0 +1,37 @@
+{config, ...}: {
+
+  users.users.calibre-server.extraGroups = [ "nextcloud" ];
+  users.users.calibre-web.extraGroups = [ "nextcloud" ];
+
+  services.calibre-server = {
+    enable = true;
+
+    host = "127.0.0.255";
+    port = 1033;
+
+    libraries = [
+      "${config.services.nextcloud.datadir}/data/clicks-services/files/calibre"
+    ];
+
+  };
+
+  services.calibre-web = {
+    enable = true;
+    listen = {
+      ip = "127.0.0.255";
+      port = 1032;
+    };
+
+    options = {
+      enableBookUploading = true;
+      enableBookConversion = true;
+
+      calibreLibrary = "${config.services.nextcloud.datadir}/data/clicks-services/files/calibre";
+
+      reverseProxyAuth = {
+        enable = false;
+        header = "keycloak_oidc";
+      }; # TODO: setup keycloak auth with oauth2_proxy
+    };
+  };
+}
\ No newline at end of file
diff --git a/modules/common/docker.nix b/modules/common/docker.nix
index 78c7f20..ae259ee 100644
--- a/modules/common/docker.nix
+++ b/modules/common/docker.nix
@@ -1,5 +1,4 @@
 { pkgs, ... }: {
   environment.systemPackages = [ pkgs.docker-compose ];
   virtualisation.docker.enable = true;
-  users.users.kavita.extraGroups = [ "docker" ];
 }
diff --git a/modules/common/nginx-routes.nix b/modules/common/nginx-routes.nix
index e94d30f..f61f3cc 100644
--- a/modules/common/nginx-routes.nix
+++ b/modules/common/nginx-routes.nix
@@ -5,8 +5,6 @@
     (Host "homebridge.coded.codes" (ReverseProxy "CodedPi:8581"))
     (Host "codedpc.coded.codes" (ReverseProxy "SamuelDesktop:3389"))
     (Host "testing.coded.codes" (ReverseProxy "SamuelDesktop:3000"))
-    (Hosts [ "kavita.coded.codes" "reading.coded.codes" ]
-      (ReverseProxy "127.0.0.1:5000"))
     (Host "clicks.codes" (Compose [
       (Path "/.well-known/matrix/"
         (CrossOrigin (File ./nginx/clicks.codes/.well-known/matrix)))
@@ -36,6 +34,14 @@
       "smtp.clicks.codes"
       "smtp.hopescaramels.com"
     ] (ReverseProxy "generic:1026"))
+    (Hosts [
+      "calibre.coded.codes"
+      "books.coded.codes"
+      "reading.coded.codes"
+      "calibre.thecoded.prof"
+      "books.thecoded.prof"
+      "reading.thecoded.prof"
+    ] (ReverseProxy "generic:1032"))
     (Hosts ["matrix.clicks.codes" "matrix.coded.codes"] (Directory "${builtins.toString
       (pkgs.schildichat-web.override {
         conf = {