diff --git a/profiles/matrix/compress-state-service.nix b/profiles/matrix/compress-state-service.nix new file mode 100644 index 00000000..30b90066 --- /dev/null +++ b/profiles/matrix/compress-state-service.nix @@ -0,0 +1,21 @@ +{ pkgs, ... }: +{ + environment.systemPackages = [ pkgs.matrix-synapse-tools.rust-synapse-compress-state ]; + systemd.services.compress-matrix-state = { + serviceConfig.Type = "oneshot"; + path = [ + pkgs.matrix-synapse-tools.rust-synapse-compress-state + ]; + script = '' + synapse_auto_compressor -p "host=/run/postgresql port=5432 user=matrix-synapse dbname=matrix-synapse" -n 2000000 -c 10000 + ''; + serviceConfig = { + User = "matrix-synapse"; + }; + }; + systemd.timers.compress-matrix-state = { + wantedBy = [ "timers.target" ]; + partOf = [ "compress-matrix-state.service" ]; + timerConfig.OnCalendar = [ "weekly" ]; + }; +} diff --git a/profiles/matrix/default.nix b/profiles/matrix/default.nix index 54431a2a..84de05b0 100644 --- a/profiles/matrix/default.nix +++ b/profiles/matrix/default.nix @@ -1,16 +1,16 @@ -{ config, lib, pkgs, ... }: +{ self, config, lib, pkgs, ... }: { imports = [ ./mautrix-telegram.nix - # ./mjolnir.nix # need to create the mod user + ./mjolnir.nix ./heisenbridge.nix + ./compress-state-service.nix ]; - environment.systemPackages = [ pkgs.matrix-synapse-tools.rust-synapse-compress-state ]; age.secrets.synapse-database-password.file = "${self}/secrets/synapse-database-password.age"; age.secrets.synapse-database-password.owner = "matrix-synapse"; - age.secrets.synapse-database-password.file = "${self}/secrets/synapse-config.age"; - age.secrets.synapse-database-password.owner = "matrix-synapse"; + age.secrets.synapse-config.file = "${self}/secrets/synapse-config.age"; + age.secrets.synapse-config.owner = "matrix-synapse"; services.matrix-synapse = { enable = true; @@ -50,7 +50,6 @@ "turn:turn.sealight.xyz:3478?transport=tcp" ]; # turn_shared_secret = config.services.coturn.static-auth-secret; - extraConfig = "/run/agenix/synapse-config"; # Example config (saved as secret??) # '' # max_upload_size: "50M" @@ -59,12 +58,13 @@ # enable_registration_without_verification: true # ''; enable_metrics = true; - enable_registration = true; + enable_registration = false; database = { name = "psycopg2"; args.passfile = "/run/agenix/synapse-database-password"; }; }; + extraConfigFiles = [ "/run/agenix/synapse-config" ]; ## coturn based TURN server integration (TURN server setup mentioned later), ## shared secret generated while configuring coturn ## and reused here (power of Nix being a real programming language) diff --git a/profiles/matrix/mautrix-telegram.nix b/profiles/matrix/mautrix-telegram.nix index de5b8703..249c706e 100644 --- a/profiles/matrix/mautrix-telegram.nix +++ b/profiles/matrix/mautrix-telegram.nix @@ -1,7 +1,7 @@ -{ config, lib, pkgs, ... }: +{ self, config, lib, pkgs, ... }: { age.secrets.telegram-matrix-env.file = "${self}/secrets/telegram-matrix-env.age"; - age.secrets.telegram-matrix-env.owner = "mautrix-telegram"; + #age.secrets.telegram-matrix-env.owner = "mautrix-telegram"; services.mautrix-telegram = { enable = true; environmentFile = "/run/agenix/telegram-matrix-env"; diff --git a/profiles/matrix/mjolnir.nix b/profiles/matrix/mjolnir.nix index 4760d388..da077295 100644 --- a/profiles/matrix/mjolnir.nix +++ b/profiles/matrix/mjolnir.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, config, ... }: +{ self, pkgs, lib, config, ... }: { age.secrets.sealight-mod-password.file = "${self}/secrets/sealight-mod-password.age"; age.secrets.sealight-mod-password.owner = "mjolnir";