From 5cf1a606e7a2d17d055c803510b68ddbbb5d2da3 Mon Sep 17 00:00:00 2001 From: Jens Nolte <git@queezle.net> Date: Wed, 17 Nov 2021 22:33:10 +0100 Subject: [PATCH] Move defaultSettings to recommendedSettings option --- modules/matrix-homeserver/default.nix | 20 +++++++++---------- modules/matrix-homeserver/postgresql.nix | 1 + ...{settings.nix => recommended-settings.nix} | 11 ++-------- 3 files changed, 12 insertions(+), 20 deletions(-) rename modules/matrix-homeserver/{settings.nix => recommended-settings.nix} (89%) diff --git a/modules/matrix-homeserver/default.nix b/modules/matrix-homeserver/default.nix index ee67cc5..00aa0db 100644 --- a/modules/matrix-homeserver/default.nix +++ b/modules/matrix-homeserver/default.nix @@ -54,18 +54,17 @@ in { settings = mkOption { type = settingsFormat.type; - apply = recursiveUpdate cfg.defaultSettings; default = {}; description = '' https://matrix-org.github.io/synapse/latest/usage/configuration/homeserver_sample_config.html ''; }; - defaultSettings = mkOption { - type = settingsFormat.type; - default = import ./settings.nix inputs; + recommendedSettings = mkOption { + type = types.bool; + default = false; description = '' - Default settings (i.e. *my* settings). Can be overwritten by setting them to '{}'. + Include recommended synapse settings, tuned for a small VPS instance with a few users (see 'recommended-settings.nix'). ''; }; @@ -189,14 +188,13 @@ in { assertion = !config.services.matrix-synapse.enable; message = "Cannot use services.matrix-synapse and queezle.matrix-homeserver at the same time."; } + ]; + + queezle.matrix-homeserver.settings = mkMerge [ + (mkIf cfg.recommendedSettings (import ./recommended-settings.nix inputs)) { - assertion = config.queezle.matrix-homeserver.settings ? max_upload_size; - message = "queezle.matrix-homeserver.settings.max_upload_size not set"; + server_name = cfg.serverName; } ]; - - queezle.matrix-homeserver.settings = { - server_name = cfg.serverName; - }; }; } diff --git a/modules/matrix-homeserver/postgresql.nix b/modules/matrix-homeserver/postgresql.nix index 2fd2cfc..6d2111d 100644 --- a/modules/matrix-homeserver/postgresql.nix +++ b/modules/matrix-homeserver/postgresql.nix @@ -4,6 +4,7 @@ with lib; let cfg = config.queezle.matrix-homeserver; in { + # TODO dedicated enable config = mkIf cfg.enable { # postgresql database service services.postgresql = { diff --git a/modules/matrix-homeserver/settings.nix b/modules/matrix-homeserver/recommended-settings.nix similarity index 89% rename from modules/matrix-homeserver/settings.nix rename to modules/matrix-homeserver/recommended-settings.nix index 2bdf726..3baab1b 100644 --- a/modules/matrix-homeserver/settings.nix +++ b/modules/matrix-homeserver/recommended-settings.nix @@ -16,9 +16,7 @@ in { global_factor = 4.0; }; - # Set to default value because it needs to be configured on nginx - max_upload_size = "50M"; - + # Generate thumbnails matching the resolution requested by clients dynamic_thumbnails = true; url_preview_enabled = true; @@ -44,14 +42,11 @@ in { "fec0::/10" ]; - # TODO TURN - enable_registration = true; registration_requires_token = true; bcrypt_rounds = 14; # Benchmarked to take >0.5s on an AMD Ryzen 9 5900X - # TODO Metrics - + # Report anonymized usage statistics report_stats = false; trusted_key_servers = [ @@ -64,6 +59,4 @@ in { minimum_length = 16; }; }; - - # TODO Push } -- GitLab