about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2023-02-12 02:15:09 +0900
committerNguyễn Gia Phong <mcsinyx@disroot.org>2023-02-12 02:15:09 +0900
commit5978e221fd6976b371982ecaf33a710fe1cee9f6 (patch)
treef3157463b791e933aadd1779d8299cb5ecaff15a
parent426235c17e4d6557744701a86783907351708af7 (diff)
downloadnixos-conf-5978e221fd6976b371982ecaf33a710fe1cee9f6.tar.gz
Use regular user for dendrite
-rw-r--r--matrix.nix22
1 files changed, 19 insertions, 3 deletions
diff --git a/matrix.nix b/matrix.nix
index 38b96ed..e883918 100644
--- a/matrix.nix
+++ b/matrix.nix
@@ -16,7 +16,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with loang configuration.  If not, see <https://www.gnu.org/licenses/>.
 
-{ config, pkgs, ... }:
+{ config, lib, pkgs, ... }:
 let
   client = {
     "m.homeserver" = {
@@ -31,12 +31,12 @@ let
   server = {
     "m.server" = "${domain}:443"; # unify with client-server
   };
+  workingDir = "/var/lib/dendrite"; # hardcoded in service
 in {
   services = {
     dendrite = {
       enable = true;
-      settings = let workingDir = "/var/lib/dendrite"; # hardcoded in service
-      in {
+      settings = {
         app_service_api.database.connection_string = "";
         federation_api.database.connection_string = "";
         global = {
@@ -79,6 +79,7 @@ in {
         "= /.well-known/matrix/server" = {
           extraConfig = ''
             add_header Content-Type application/json;
+            add_header Access-Control-Allow-Origin *;
           '';
           return = "200 '${builtins.toJSON server}'";
         };
@@ -113,4 +114,19 @@ in {
       package = pkgs.postgresql_14;
     };
   };
+
+  systemd.services.dendrite.serviceConfig = {
+    DynamicUser = lib.mkForce false;
+    User = "dendrite";
+    Group = "dendrite";
+  };
+
+  users = {
+    users.dendrite = {
+      isSystemUser = true;
+      group = "dendrite";
+      home = workingDir;
+    };
+    groups.dendrite = {};
+  };
 }