Initial commit
This commit is contained in:
63
module.nix
Normal file
63
module.nix
Normal file
@@ -0,0 +1,63 @@
|
||||
self: { pkgs, config, lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
mkEnableOption
|
||||
mkIf
|
||||
types
|
||||
;
|
||||
|
||||
cfg = config.services.synapse-revitalization;
|
||||
in {
|
||||
options.services.synapse-revitalization = {
|
||||
enable = mkEnableOption "Enable synapse-revitalization service";
|
||||
adminAuthTokenFile = mkOption {
|
||||
type = types.path;
|
||||
description = "File containing admin user's authentication token";
|
||||
};
|
||||
serverKeyFile = mkOption {
|
||||
type = types.path;
|
||||
description = "Synapse server signing key file";
|
||||
default = "/var/lib/matrix-synapse/homeserver.signing.key";
|
||||
};
|
||||
serverName = mkOption {
|
||||
type = types.str;
|
||||
description = "Synapse server's name";
|
||||
default = config.services.matrix-synapse.settings.server_name;
|
||||
};
|
||||
serverFQDN = mkOption {
|
||||
type = types.str;
|
||||
description = "Synapse server's fqdn";
|
||||
};
|
||||
package = self.packages.x86_64-linux.synapse-revitalization;
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable) {
|
||||
systemd.services."synapse-revitalization" =
|
||||
let pkg = "${pkgs.synapse-revitalization}/bin/synapse-revitalization";
|
||||
script = pkgs.writeShellScript "synapse-revitalization-script" ''
|
||||
journalctl -f -u matrix-synapse -o cat |
|
||||
while read -r line; do
|
||||
echo "$line" | grep "as we're not in the room" && ${pkg} "$line" &
|
||||
echo "$line" | grep "Ignoring PDU for unknown room_id" && ${pkg} "$line" &
|
||||
done
|
||||
'';
|
||||
in {
|
||||
enable = true;
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = "root";
|
||||
Group = "root";
|
||||
ExecStart = script;
|
||||
Restart = "always";
|
||||
};
|
||||
environment = {
|
||||
"SYNAPSE_REVITALIZATION_ADMIN_AUTH_TOKEN_FILE" = cfg.adminAuthTokenFile;
|
||||
"SYNAPSE_REVITALIZATION_SERVER_KEY_FILE" = cfg.serverKeyFile;
|
||||
"SYNAPSE_REVITALIZATION_SERVER_NAME" = cfg.serverName;
|
||||
"SYNAPSE_REVITALIZATION_SERVER_ADDRESS" = cfg.serverFQDN;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user