2024-11-17 00:08:02 +01:00
|
|
|
{ config, lib, fp, unstablePkgs, inputs, ... }:
|
2024-10-13 00:16:39 +02:00
|
|
|
|
2024-10-13 04:45:06 +02:00
|
|
|
let
|
|
|
|
cfg = config.services.matrix-hookshot;
|
|
|
|
webhookListenAddress = "127.0.0.1";
|
2024-10-13 06:28:50 +02:00
|
|
|
webhookListenPort = 8435;
|
2024-10-13 04:45:06 +02:00
|
|
|
in
|
2024-10-13 00:16:39 +02:00
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
./module.nix
|
|
|
|
];
|
|
|
|
|
2024-10-14 15:46:58 +02:00
|
|
|
sops.secrets."matrix/hookshot/as_token" = {
|
2024-11-17 00:08:02 +01:00
|
|
|
sopsFile = fp /secrets/bicep/matrix.yaml;
|
2024-10-14 15:46:58 +02:00
|
|
|
key = "hookshot/as_token";
|
|
|
|
};
|
|
|
|
sops.secrets."matrix/hookshot/hs_token" = {
|
2024-11-17 00:08:02 +01:00
|
|
|
sopsFile = fp /secrets/bicep/matrix.yaml;
|
2024-10-14 15:46:58 +02:00
|
|
|
key = "hookshot/hs_token";
|
|
|
|
};
|
|
|
|
|
|
|
|
sops.templates."hookshot-registration.yaml" = {
|
2024-10-13 00:16:39 +02:00
|
|
|
owner = config.users.users.matrix-synapse.name;
|
|
|
|
group = config.users.groups.keys-matrix-registrations.name;
|
2024-10-14 15:46:58 +02:00
|
|
|
content = ''
|
|
|
|
id: matrix-hookshot
|
|
|
|
as_token: "${config.sops.placeholder."matrix/hookshot/as_token"}"
|
|
|
|
hs_token: "${config.sops.placeholder."matrix/hookshot/hs_token"}"
|
|
|
|
namespaces:
|
|
|
|
rooms: []
|
|
|
|
users:
|
|
|
|
- regex: "@_webhooks_.*:pvv.ntnu.no"
|
|
|
|
exclusive: true
|
|
|
|
- regex: "@bot_feeds:pvv.ntnu.no"
|
|
|
|
exclusive: true
|
|
|
|
aliases: []
|
|
|
|
|
|
|
|
sender_localpart: hookshot
|
|
|
|
url: "http://${cfg.settings.bridge.bindAddress}:${toString cfg.settings.bridge.port}"
|
|
|
|
rate_limited: false
|
|
|
|
|
|
|
|
# If enabling encryption
|
|
|
|
de.sorunome.msc2409.push_ephemeral: true
|
|
|
|
push_ephemeral: true
|
|
|
|
org.matrix.msc3202: true
|
|
|
|
'';
|
2024-10-13 00:16:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.matrix-hookshot = {
|
2024-10-14 15:46:58 +02:00
|
|
|
serviceConfig.SupplementaryGroups = [
|
|
|
|
config.users.groups.keys-matrix-registrations.name
|
|
|
|
];
|
2024-10-13 00:16:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
services.matrix-hookshot = {
|
|
|
|
enable = true;
|
|
|
|
package = unstablePkgs.matrix-hookshot;
|
2024-10-14 15:46:58 +02:00
|
|
|
registrationFile = config.sops.templates."hookshot-registration.yaml".path;
|
2024-10-13 00:16:39 +02:00
|
|
|
settings = {
|
|
|
|
bridge = {
|
|
|
|
bindAddress = "127.0.0.1";
|
2024-10-13 06:28:50 +02:00
|
|
|
domain = "pvv.ntnu.no";
|
2024-10-13 00:16:39 +02:00
|
|
|
url = "https://matrix.pvv.ntnu.no";
|
|
|
|
mediaUrl = "https://matrix.pvv.ntnu.no";
|
|
|
|
port = 9993;
|
|
|
|
};
|
|
|
|
listeners = [
|
|
|
|
{
|
2024-10-13 04:45:06 +02:00
|
|
|
bindAddress = webhookListenAddress;
|
|
|
|
port = webhookListenPort;
|
2024-10-13 00:16:39 +02:00
|
|
|
resources = [
|
|
|
|
"webhooks"
|
2024-10-13 04:45:06 +02:00
|
|
|
# "metrics"
|
|
|
|
# "provisioning"
|
2024-10-13 00:16:39 +02:00
|
|
|
"widgets"
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
generic = {
|
|
|
|
enabled = true;
|
2024-10-13 04:45:06 +02:00
|
|
|
outbound = true;
|
2024-10-13 06:28:50 +02:00
|
|
|
urlPrefix = "https://hookshot.pvv.ntnu.no/webhook/";
|
|
|
|
userIdPrefix = "_webhooks_";
|
|
|
|
allowJsTransformationFunctions = false;
|
|
|
|
waitForComplete = false;
|
2024-10-13 00:16:39 +02:00
|
|
|
};
|
|
|
|
feeds = {
|
|
|
|
enabled = true;
|
2024-10-13 06:28:50 +02:00
|
|
|
pollIntervalSeconds = 600;
|
2024-10-13 00:16:39 +02:00
|
|
|
};
|
2024-10-13 06:28:50 +02:00
|
|
|
|
|
|
|
serviceBots = [
|
|
|
|
{ localpart = "bot_feeds";
|
|
|
|
displayname = "Aya";
|
|
|
|
avatar = ./feeds.png;
|
|
|
|
prefix = "!aya";
|
|
|
|
service = "feeds";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
permissions = [
|
|
|
|
# Users of the PVV Server
|
|
|
|
{ actor = "pvv.ntnu.no";
|
|
|
|
services = [ { service = "*"; level = "commands"; } ];
|
|
|
|
}
|
|
|
|
# Members of Medlem space (for people with their own hs)
|
|
|
|
{ actor = "!pZOTJQinWyyTWaeOgK:pvv.ntnu.no";
|
|
|
|
services = [ { service = "*"; level = "commands"; } ];
|
|
|
|
}
|
|
|
|
# Members of Drift
|
|
|
|
{ actor = "!eYgeufLrninXxQpYml:pvv.ntnu.no";
|
|
|
|
services = [ { service = "*"; level = "admin"; } ];
|
|
|
|
}
|
|
|
|
# Dan bootstrap
|
|
|
|
{ actor = "@dandellion:dodsorf.as";
|
|
|
|
services = [ { service = "*"; level = "admin"; } ];
|
|
|
|
}
|
|
|
|
];
|
2024-10-13 00:16:39 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-14 15:46:58 +02:00
|
|
|
services.matrix-hookshot.serviceDependencies = [
|
|
|
|
"matrix-synapse.target"
|
|
|
|
"nginx.service"
|
|
|
|
];
|
2024-10-13 00:16:39 +02:00
|
|
|
|
|
|
|
services.matrix-synapse-next.settings = {
|
2024-10-14 15:46:58 +02:00
|
|
|
app_service_config_files = [
|
|
|
|
config.sops.templates."hookshot-registration.yaml".path
|
|
|
|
];
|
2024-10-13 00:16:39 +02:00
|
|
|
};
|
2024-10-13 04:45:06 +02:00
|
|
|
|
|
|
|
services.nginx.virtualHosts."hookshot.pvv.ntnu.no" = {
|
|
|
|
enableACME = true;
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://${webhookListenAddress}:${toString webhookListenPort}";
|
|
|
|
};
|
|
|
|
};
|
2024-10-13 00:16:39 +02:00
|
|
|
}
|