prettify element
This commit is contained in:
@@ -9,49 +9,70 @@
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
legacyCfg = config.hectic.services.matrix;
|
||||
hasClusterCfg = config.hectic ? generic && config.hectic.generic ? matrix-cluster;
|
||||
clusterCfg = if hasClusterCfg then config.hectic.generic.matrix-cluster else null;
|
||||
clusterSynapseEnabled =
|
||||
if hasClusterCfg
|
||||
then clusterCfg.enable
|
||||
&& (if clusterCfg.overrideEnableSynapse != null then clusterCfg.overrideEnableSynapse else clusterCfg.role == "primary")
|
||||
else false;
|
||||
enabled = legacyCfg.enable || clusterSynapseEnabled;
|
||||
matrixDomain = if legacyCfg.enable then legacyCfg.matrixDomain else if hasClusterCfg then clusterCfg.matrixDomain else "";
|
||||
jitsiPreferredDomain =
|
||||
if legacyCfg.enable && config.hectic.services.jitsi.enable
|
||||
then config.hectic.services.jitsi.hostName
|
||||
else if hasClusterCfg then clusterCfg.jitsi.preferredDomain else null;
|
||||
cfg = config.hectic.services.element;
|
||||
nonEmptyStr = lib.types.strMatching ".+";
|
||||
generatedSettings = {
|
||||
default_server_config = {
|
||||
"m.homeserver".base_url = cfg.homeserverBaseUrl;
|
||||
"m.homeserver".server_name = cfg.homeserverServerName;
|
||||
"m.identity_server".base_url = "https://vector.im";
|
||||
};
|
||||
|
||||
room_directory.servers = [ cfg.homeserverServerName ];
|
||||
|
||||
jitsi = lib.optionalAttrs (cfg.jitsiPreferredDomain != null) {
|
||||
preferred_domain = cfg.jitsiPreferredDomain;
|
||||
};
|
||||
|
||||
default_theme = "dark";
|
||||
show_labs_settings = true;
|
||||
};
|
||||
in {
|
||||
config = lib.mkIf enabled {
|
||||
services.nginx.virtualHosts."element.${matrixDomain}" = {
|
||||
options.hectic.services.element = {
|
||||
enable = lib.mkEnableOption "Element web client";
|
||||
|
||||
hostName = lib.mkOption {
|
||||
type = nonEmptyStr;
|
||||
description = "FQDN serving the Element web client.";
|
||||
};
|
||||
|
||||
homeserverBaseUrl = lib.mkOption {
|
||||
type = nonEmptyStr;
|
||||
description = "Public Matrix homeserver base URL used by Element.";
|
||||
};
|
||||
|
||||
homeserverServerName = lib.mkOption {
|
||||
type = nonEmptyStr;
|
||||
description = "Matrix server name presented by Element.";
|
||||
};
|
||||
|
||||
jitsiPreferredDomain = lib.mkOption {
|
||||
type = lib.types.nullOr nonEmptyStr;
|
||||
default = null;
|
||||
description = "Preferred Jitsi domain, or null to leave it unset.";
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.attrsOf (pkgs.formats.json {}).type;
|
||||
default = {};
|
||||
description = ''
|
||||
Extra Element config recursively merged over generated defaults.
|
||||
Values here may override generated keys. Settings are PUBLIC in the
|
||||
Nix store and served config.json; do not put secrets here.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.nginx.enable = true;
|
||||
services.nginx.virtualHosts.${cfg.hostName} = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
|
||||
locations."= /config.element.${matrixDomain}.json".return = "302 /config.json";
|
||||
locations."= /config.${cfg.hostName}.json".return = "302 /config.json";
|
||||
|
||||
root = pkgs.hectic.element-web.override {
|
||||
conf = {
|
||||
default_server_config = {
|
||||
"m.homeserver".base_url = "https://${matrixDomain}";
|
||||
"m.homeserver".server_name = matrixDomain;
|
||||
"m.identity_server".base_url = "https://vector.im";
|
||||
};
|
||||
|
||||
room_directory.servers = [
|
||||
matrixDomain
|
||||
];
|
||||
|
||||
hectic.videoMessages.enabled = true;
|
||||
|
||||
jitsi = lib.optionalAttrs (jitsiPreferredDomain != null) {
|
||||
preferred_domain = jitsiPreferredDomain;
|
||||
};
|
||||
|
||||
default_theme = "dark";
|
||||
show_labs_settings = true;
|
||||
};
|
||||
conf = lib.recursiveUpdate generatedSettings cfg.settings;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
self,
|
||||
}: {
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
config,
|
||||
...
|
||||
@@ -66,6 +65,14 @@ in {
|
||||
hostName = jitsiHost;
|
||||
};
|
||||
|
||||
hectic.services.element = {
|
||||
enable = true;
|
||||
hostName = elementEntryDomain;
|
||||
homeserverBaseUrl = "https://${polandEntryDomain}";
|
||||
homeserverServerName = matrixHost;
|
||||
jitsiPreferredDomain = jitsiHost;
|
||||
};
|
||||
|
||||
# NOTE(yukkop): disk was provisioned outside disko, so the expected partition
|
||||
# label does not exist. Pin root to the live filesystem UUID so stage 1 can
|
||||
# mount `/` reliably.
|
||||
@@ -171,34 +178,6 @@ in {
|
||||
proxyPass = "http://127.0.0.1:8008";
|
||||
};
|
||||
};
|
||||
|
||||
virtualHosts.${elementEntryDomain} = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
|
||||
locations."= /config.${elementEntryDomain}.json".return = "302 /config.json";
|
||||
|
||||
root = pkgs.hectic.element-web.override {
|
||||
conf = {
|
||||
default_server_config = {
|
||||
"m.homeserver".base_url = "https://${polandEntryDomain}";
|
||||
"m.homeserver".server_name = matrixHost;
|
||||
"m.identity_server".base_url = "https://vector.im";
|
||||
};
|
||||
|
||||
jitsi = {
|
||||
preferred_domain = jitsiHost;
|
||||
};
|
||||
|
||||
hectic.videoMessages.enabled = true;
|
||||
|
||||
room_directory.servers = [ matrixHost ];
|
||||
|
||||
default_theme = "dark";
|
||||
show_labs_settings = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
sops.secrets."matrix/signing-key" = {
|
||||
|
||||
Reference in New Issue
Block a user