summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/misc/mx-puppet-discord.nix
diff options
context:
space:
mode:
authorcolin <colin@uninsane.org>2023-01-16 06:23:25 +0000
committercolin <colin@uninsane.org>2023-01-16 06:23:25 +0000
commit87c877fff84717478a96d1b0c65bd2febd350dea (patch)
treeba5541ff38826ed2149ba2c438a97bbe864c09fe /nixos/modules/services/misc/mx-puppet-discord.nix
parent27b97d2f872511886cb02e96a520bdd1eef1a190 (diff)
nixos/mx-puppet-discord: move into matrix category
Diffstat (limited to 'nixos/modules/services/misc/mx-puppet-discord.nix')
-rw-r--r--nixos/modules/services/misc/mx-puppet-discord.nix122
1 files changed, 0 insertions, 122 deletions
diff --git a/nixos/modules/services/misc/mx-puppet-discord.nix b/nixos/modules/services/misc/mx-puppet-discord.nix
deleted file mode 100644
index 36c9f8b122ea..000000000000
--- a/nixos/modules/services/misc/mx-puppet-discord.nix
+++ /dev/null
@@ -1,122 +0,0 @@
-{ config, pkgs, lib, ... }:
-
-with lib;
-
-let
- dataDir = "/var/lib/mx-puppet-discord";
- registrationFile = "${dataDir}/discord-registration.yaml";
- cfg = config.services.mx-puppet-discord;
- settingsFormat = pkgs.formats.json {};
- settingsFile = settingsFormat.generate "mx-puppet-discord-config.json" cfg.settings;
-
-in {
- options = {
- services.mx-puppet-discord = {
- enable = mkEnableOption (lib.mdDoc ''
- mx-puppet-discord is a discord puppeting bridge for matrix.
- It handles bridging private and group DMs, as well as Guilds (servers)
- '');
-
- settings = mkOption rec {
- apply = recursiveUpdate default;
- inherit (settingsFormat) type;
- default = {
- bridge.port = 8434;
- presence = {
- enabled = true;
- interval = 500;
- };
- provisioning.whitelist = [ ];
- relay.whitelist = [ ];
-
- # variables are preceded by a colon.
- namePatterns = {
- user = ":name";
- userOverride = ":displayname";
- room = ":name";
- group = ":name";
- };
-
- #defaults to sqlite but can be configured to use postgresql with
- #connstring
- database.filename = "${dataDir}/database.db";
- logging = {
- console = "info";
- lineDateFormat = "MMM-D HH:mm:ss.SSS";
- };
- };
- example = literalExpression ''
- {
- bridge = {
- bindAddress = "localhost";
- domain = "example.com";
- homeserverUrl = "https://example.com";
- };
-
- provisioning.whitelist = [ "@admin:example.com" ];
- relay.whitelist = [ "@.*:example.com" ];
- }
- '';
- description = lib.mdDoc ''
- {file}`config.yaml` configuration as a Nix attribute set.
- Configuration options should match those described in
- [
- sample.config.yaml](https://github.com/matrix-discord/mx-puppet-discord/blob/master/sample.config.yaml).
- '';
- };
- serviceDependencies = mkOption {
- type = with types; listOf str;
- default = optional config.services.matrix-synapse.enable "matrix-synapse.service";
- defaultText = literalExpression ''
- optional config.services.matrix-synapse.enable "matrix-synapse.service"
- '';
- description = lib.mdDoc ''
- List of Systemd services to require and wait for when starting the application service.
- '';
- };
- };
- };
-
- config = mkIf cfg.enable {
- systemd.services.mx-puppet-discord = {
- description = "Matrix to Discord puppeting bridge";
-
- wantedBy = [ "multi-user.target" ];
- wants = [ "network-online.target" ] ++ cfg.serviceDependencies;
- after = [ "network-online.target" ] ++ cfg.serviceDependencies;
-
- preStart = ''
- # generate the appservice's registration file if absent
- if [ ! -f '${registrationFile}' ]; then
- ${pkgs.mx-puppet-discord}/bin/mx-puppet-discord -r -c ${settingsFile} \
- -f ${registrationFile}
- fi
- '';
-
- serviceConfig = {
- Type = "simple";
- Restart = "always";
-
- ProtectSystem = "strict";
- ProtectHome = true;
- ProtectKernelTunables = true;
- ProtectKernelModules = true;
- ProtectControlGroups = true;
-
- DynamicUser = true;
- PrivateTmp = true;
- WorkingDirectory = pkgs.mx-puppet-discord;
- StateDirectory = baseNameOf dataDir;
- UMask = "0027";
-
- ExecStart = ''
- ${pkgs.mx-puppet-discord}/bin/mx-puppet-discord \
- -c ${settingsFile} \
- -f ${registrationFile}
- '';
- };
- };
- };
-
- meta.maintainers = with maintainers; [ govanify ];
-}