fix: element

This commit is contained in:
2026-05-23 23:11:58 +00:00
parent 4c0a178646
commit 0eecea6324
2 changed files with 26 additions and 14 deletions

View File

@@ -9,9 +9,15 @@
config, config,
... ...
}: let }: let
cfg = config.hectic.services.matrix; legacyCfg = config.hectic.services.matrix;
clusterCfg = config.hectic.generic.matrix-cluster;
clusterSynapseEnabled =
clusterCfg.enable
&& (if clusterCfg.overrideEnableSynapse != null then clusterCfg.overrideEnableSynapse else clusterCfg.role == "primary");
enabled = legacyCfg.enable || clusterSynapseEnabled;
matrixDomain = if legacyCfg.enable then legacyCfg.matrixDomain else clusterCfg.matrixDomain;
in { in {
config = lib.mkIf cfg.enable (let config = lib.mkIf enabled (let
keyFile = "/run/livekit.key"; keyFile = "/run/livekit.key";
in { in {
services.livekit = { services.livekit = {
@@ -23,7 +29,7 @@ in {
services.lk-jwt-service = { services.lk-jwt-service = {
enable = true; enable = true;
livekitUrl = "wss://${cfg.matrixDomain}/livekit/sfu"; livekitUrl = "wss://${matrixDomain}/livekit/sfu";
inherit keyFile; inherit keyFile;
}; };
@@ -40,11 +46,11 @@ in {
}; };
systemd.services.lk-jwt-service.environment.LIVEKIT_FULL_ACCESS_HOMESERVERS = systemd.services.lk-jwt-service.environment.LIVEKIT_FULL_ACCESS_HOMESERVERS =
cfg.matrixDomain; matrixDomain;
services.nginx = { services.nginx = {
enable = true; enable = true;
virtualHosts.${cfg.matrixDomain} = { virtualHosts.${matrixDomain} = {
forceSSL = true; forceSSL = true;
enableACME = true; enableACME = true;
@@ -57,18 +63,18 @@ in {
''; '';
return = ''200 '{ return = ''200 '{
"m.homeserver": { "m.homeserver": {
"base_url": "https://${cfg.matrixDomain}" "base_url": "https://${matrixDomain}"
}, },
"m.identity_server": { "m.identity_server": {
"base_url": "https://vector.im" "base_url": "https://vector.im"
}, },
"org.matrix.msc3575.proxy": { "org.matrix.msc3575.proxy": {
"url": "https://${cfg.matrixDomain}" "url": "https://${matrixDomain}"
}, },
"org.matrix.msc4143.rtc_foci": [ "org.matrix.msc4143.rtc_foci": [
{ {
"type": "livekit", "type": "livekit",
"livekit_service_url": "https://${cfg.matrixDomain}/livekit/jwt" "livekit_service_url": "https://${matrixDomain}/livekit/jwt"
} }
] ]
}' ''; }' '';

View File

@@ -9,23 +9,29 @@
config, config,
... ...
}: let }: let
cfg = config.hectic.services.matrix; legacyCfg = config.hectic.services.matrix;
clusterCfg = config.hectic.generic.matrix-cluster;
clusterSynapseEnabled =
clusterCfg.enable
&& (if clusterCfg.overrideEnableSynapse != null then clusterCfg.overrideEnableSynapse else clusterCfg.role == "primary");
enabled = legacyCfg.enable || clusterSynapseEnabled;
matrixDomain = if legacyCfg.enable then legacyCfg.matrixDomain else clusterCfg.matrixDomain;
in { in {
config = lib.mkIf cfg.enable { config = lib.mkIf enabled {
services.nginx.virtualHosts."element.${cfg.matrixDomain}" = { services.nginx.virtualHosts."element.${matrixDomain}" = {
enableACME = true; enableACME = true;
forceSSL = true; forceSSL = true;
root = pkgs.element-web.override { root = pkgs.element-web.override {
conf = { conf = {
default_server_config = { default_server_config = {
"m.homeserver".base_url = "https://${cfg.matrixDomain}"; "m.homeserver".base_url = "https://${matrixDomain}";
"m.homeserver".server_name = cfg.matrixDomain; "m.homeserver".server_name = matrixDomain;
"m.identity_server".base_url = "https://vector.im"; "m.identity_server".base_url = "https://vector.im";
}; };
room_directory.servers = [ room_directory.servers = [
cfg.matrixDomain matrixDomain
]; ];
default_theme = "dark"; default_theme = "dark";