The Complete Computing Environment

Matrix Synapse

LifeTechEmacsTopicsArcology

I've been in the Matrix.org Ecosystem for a while and use some bridging software to Illegally integrate other chat networks in to a single client which syncs between my phone and desktops and etc.

Synapse on NixOS

This is an Arroyo NixOS module used in My Wobserver Configuration.

,#+ARROYONIXOSMODULE: nixos/matrix.nix

{ ... }:

let useSSL = false; # for VM testing... should make this an option...
in {
  services.postgresql.ensureUsers = [
    {
      name = "matrix-synapse";
      ensurePermissions = {
        "DATABASE synapse" = "ALL PRIVILEGES";
      };
    }
  ];

  users.users.matrix-synapse.createHome = true;
  users.users.matrix-synapse.home = "/srv/matrix-synapse";

  services.nginx.virtualHosts."matrix.fontkeming.fail" = {
    listen = [
      { addr = "0.0.0.0"; port = 8448; }
      { addr = "0.0.0.0"; port = 80; }
      # { addr = "0.0.0.0"; port = 443; ssl = true; }
    ];
    forceSSL = useSSL;

    locations."/_matrix" = {
      proxyPass = "http://127.0.0.1:8008/_matrix";
      extraConfig = ''
        client_max_body_size 16m;
        access_log off;
      '';
    };
  };

  services.matrix-synapse = {
    enable = true;
    dataDir = "/srv/matrix-synapse";
    settings = {
      server_name = "kickass.systems";
      public_baseurl = "https://matrix.fontkeming.fail";

      enable_metrics = true;
      report_stats = true;

      url_preview_enabled = true;

      database.name = "psycopg2";
      database.args.user = "synapse";
      database.args.database = "synapse";

      secondary_directory_servers = [
        "matrix.org"
        "cybre.space"
      ];

      retention = {
        default_policy = {
          min_lifetime = "1d";
          max_lifetime = "26w";
        };
        allowed_liftetime_min = "1d";
        allowed_liftetime_max = "1y";
      };

      thumbnail_sizes = [
        { width = 24;
          height = 24;
          method = "crop"; }
        { width = 32;
          height = 32;
          method = "crop"; }
        { width = 96;
          height = 96;
          method = "crop"; }
        { width = 320;
          height = 240;
          method = "scale"; }
        { width = 640;
          height = 480;
          method = "scale"; }
        { width = 800;
          height = 600;
          method = "scale"; }
      ];

      listeners = [
        { bind_addresses = [ "127.0.0.1" ] ;
          port = 8008;
          resources = [
            { compress = true;
              names = [ "client" ]; }
            { compress = false;
              names = [ "federation" ]; } ];
          tls = false;
          type = "http";
          x_forwarded = true;
        } 
      ];
    };
  };
}

mx-puppet-discord

mx-puppet-discord allows a savvy Discord user to log in to their discord guilds and chat in them through a Matrix client. Definitely don't do a crimes with it, I'm sure I'll be banned for this indiscretion some day but this bridging is the core value proposition of Matrix for me.

It's primarily operated via chat commands. I am mostly trusting the default nixpkgs configuration.

{ ... }:

{
  services.mx-puppet-discord.enable = true;
  # services.matrix-synapse.extraConfig = ''
  # '';
  services.mx-puppet-discord.settings = {
    database.filename = "/srv/matrix-puppet-discord/database.db";
    bridge = {
      port = 8091;
      bindAddress = 0.0.0.0;
      domain = "kickass.systems";
      homeserverUrl = "https://matrix.fontkeming.fail";
    };
    provisioning.whitelist = ["@rrix:kickass\\.systems"];
  };
}

NEXT matrix-dimension

NEXT mx-puppet-slack

NEXT validate database setup

NEXT evaluate matrix-homeserver

https://github.com/queezle42/matrix-homeserver

This seems nice maybe