My Self-Hosted All-in-One Messanger

blog matrix nix

published 2023-01-02 14:22

updated 2023-05-27 01:37

tl;dr: I'm running my own Beeper on my own Infrastructure entirely managed through NixOS

I've been running running a Matrix server since late 2016. It was my first foray into hosting a large application out on the public internet for both myself and my friends. At the time Matrix was quite unstable and new, coupled with my first time being a server administrator meant lots of downtime. Since then the protocol, server (synapse) and my own DevOps skills have come a long way, and now I run for me and some friends with generally not too much trouble.

The thing that attracted me to Matrix was the promise of interoperability. Slightly over a decade ago, interoperability was fairly normal, both for chats and web updates. RSS being the defacto method of pushing updates to your users (long before the annoying trend of trading my email for updates). XMPP and Pidgen being standards that even large corporations supported (Whatsapp and Google Chat were both originally XMPP protocols), but those days are long gone. Being a terminally online individual, I'm on a lot of different networks. I do refuse to join particularly problematic networks, but largely if there's people I wish to interact with, I'll join the network. In today's world of hyper-capitalist, growth-centred corporations that means a staggering number of networks. Counting chat only there's: Signal, Telegram, Wire, Slack, Discord, Zulip, Whatsapp, Messenger, Rocket.Chat, Gitter, IRC and SMS. That's far too many apps just to communicate with people...

Enter Matrix. A newfangled pseudo-clone of XMPP, but for the "modern" era. Designed to support extensions and bridges, the old dream is once more becoming reality once more. Well, technically if you're willing to shell out cold hard cash, you could pay experts to do this for you, but where's the fun in that? Matrix being open source and entirely self-hostable I wanted to do it myself.

Running a Matrix-Synapse Server on NixOS has tons of tutorials, in fact the NixOS module makes it incredibly simple to run a Synapse server. However there are very few for running bridges. Originally being primarily concerned with Telegram, and it being the first bridge packaged and "module-d" for NixOS, I set out on configuring it myself, and managed to fairly easily simply following the documentation. At the time (2019? 2020?) my Nix skills where quite minimal, so I couldn't figure out how to package or create a module, so I didn't try the others for a while. The story is quite different now. For one, I do know how to package things and modularize them. So I did that for heisenbridge, an IRC bridge for Matrix. Then yesterday I found out about this, which is a flake for the matrix app-services all neatly packaged up and modularized. Using that flake I managed to get the rest of the networks I cared about onto my home-server; Discord, Signal and Whatsapp. It turns out their mautrix-discord package was broken, and I decided to just package it myself, especially since Go applications are really simple to build. The mautrix-signal module was also busted, primarily because it was using a separate user and group than signald, which it needs access to. One lib.mkForce later and we're in business. With this flake, all it takes is a handful of lines of Nix code to start and run all the bridges that have been packaged, which has been awesome. Another 2-year cycle for completing another large thing on my to-do list. Now I can access all my messages through a single interface 😁

All the source code for my nix configuration files for matrix is available online

Despite really enjoying the benefits of a single interface, there are certainly downsides to this approach. For one, my mobile element is awfully slow now, though using a 5 year old phone may have something to do with that (not that that is an acceptable excuse for slow apps...) The experience is also not the best, particularly around profile pictures, which for some reason don't work for various bridges. Voice chat for the bridges also generally isn't supported, though I generally prefer text anyway so I don't mind so much. I get to live my most terminally-online life.