about summary refs log tree commit diff
path: root/modules/matrix
diff options
context:
space:
mode:
authorazahi <azat@bahawi.net>2025-02-05 17:18:02 +0300
committerazahi <azat@bahawi.net>2025-02-05 17:18:02 +0300
commitec25e095a26ad1e4823887a6653132948ebc5f87 (patch)
treef3d9e02f13515e7c63bc716dc39e193924589bc8 /modules/matrix
parent2025-02-02 (diff)
2025-02-05
Diffstat (limited to 'modules/matrix')
-rw-r--r--modules/matrix/dendrite.nix29
-rw-r--r--modules/matrix/element.nix15
2 files changed, 22 insertions, 22 deletions
diff --git a/modules/matrix/dendrite.nix b/modules/matrix/dendrite.nix
index c391ba0..89704ea 100644
--- a/modules/matrix/dendrite.nix
+++ b/modules/matrix/dendrite.nix
@@ -6,22 +6,21 @@
   this,
   ...
 }:
-with lib;
 let
   cfg = config.nixfiles.modules.matrix.dendrite;
 in
 {
   options.nixfiles.modules.matrix.dendrite = {
-    enable = mkEnableOption "Dendrite Matrix server";
+    enable = lib.mkEnableOption "Dendrite Matrix server";
 
-    port = mkOption {
+    port = lib.mkOption {
       description = "Port.";
-      type = with types; port;
+      type = lib.types.port;
       default = 8008;
     };
 
-    domain = mkOption {
-      type = types.str;
+    domain = lib.mkOption {
+      type = lib.types.str;
       default = config.networking.domain;
       description = "Domain name sans protocol scheme.";
     };
@@ -31,7 +30,7 @@ in
     let
       db = "dendrite";
     in
-    mkIf cfg.enable {
+    lib.mkIf cfg.enable {
       ark.directories = [
         "/var/lib/dendrite"
         "/var/lib/private/dendrite"
@@ -58,14 +57,16 @@ in
                 add_header Content-Type application/json;
                 add_header Access-Control-Allow-Origin *;
               '';
-              return = "200 '${generators.toJSON { } { "m.server" = "${cfg.domain}:443"; }}'";
+              return = "200 '${lib.generators.toJSON { } { "m.server" = "${cfg.domain}:443"; }}'";
             };
             "= /.well-known/matrix/client" = {
               extraConfig = ''
                 add_header Content-Type application/json;
                 add_header Access-Control-Allow-Origin *;
               '';
-              return = "200 '${generators.toJSON { } { "m.homeserver".base_url = "https://${cfg.domain}"; }}'";
+              return = "200 '${
+                lib.generators.toJSON { } { "m.homeserver".base_url = "https://${cfg.domain}"; }
+              }'";
             };
           };
         };
@@ -119,7 +120,7 @@ in
         serviceConfig =
           let
             needsPrivileges = cfg.port < 1024;
-            capabilities = [ "" ] ++ optionals needsPrivileges [ "CAP_NET_BIND_SERVICE" ];
+            capabilities = [ "" ] ++ lib.optionals needsPrivileges [ "CAP_NET_BIND_SERVICE" ];
           in
           {
             Restart = "on-failure";
@@ -185,13 +186,13 @@ in
                   ];
                 };
               in
-              concatStringsSep " " [
-                (getExe pkgs.envsubst)
+              lib.concatStringsSep " " [
+                (lib.getExe pkgs.envsubst)
                 "-i ${(pkgs.formats.yaml { }).generate "dendrite.yaml" settings}"
                 "-o /run/dendrite/dendrite.yaml"
               ];
-            ExecStart = concatStringsSep " " [
-              (getExe' pkgs.dendrite "dendrite")
+            ExecStart = lib.concatStringsSep " " [
+              (lib.getExe' pkgs.dendrite "dendrite")
               "--config /run/dendrite/dendrite.yaml"
               "--http-bind-address 127.0.0.1:${toString cfg.port}"
             ];
diff --git a/modules/matrix/element.nix b/modules/matrix/element.nix
index 01b991e..c1c29a7 100644
--- a/modules/matrix/element.nix
+++ b/modules/matrix/element.nix
@@ -4,28 +4,27 @@
   pkgs,
   ...
 }:
-with lib;
 let
   cfg = config.nixfiles.modules.matrix.element;
 in
 {
   options.nixfiles.modules.matrix.element = {
-    enable = mkEnableOption "Element, a Matrix web interface";
+    enable = lib.mkEnableOption "Element, a Matrix web interface";
 
-    domain = mkOption {
+    domain = lib.mkOption {
       description = "Domain name sans protocol scheme.";
-      type = with types; nullOr str;
+      type = with lib.types; nullOr str;
       default = "element.${config.networking.domain}";
     };
 
-    homeserver = mkOption {
+    homeserver = lib.mkOption {
       description = "Default Matrix homeserver.";
-      type = with types; str;
-      default = my.domain.azahi;
+      type = lib.types.str;
+      default = lib.my.domain.azahi;
     };
   };
 
-  config = mkIf cfg.enable {
+  config = lib.mkIf cfg.enable {
     assertions = [
       {
         assertion =

Consider giving Nix/NixOS a try! <3