Setting up WeeChat and Glowing Bear on NixOS

November 17, 2020

So much conversation in the Haskell and Nix ecosystems happens on IRC. One of the disadvantages of IRC is that you can’t log in (identify) as the same user on multiple machines. This is especially annoying when switching between mobile and desktop. Some proprietary services, like IRCCloud, will keep you connected and provide you a cross-platform IRC interface. You can, however, achieve the same result using a few free and open source technologies.

We’re going to set up a server that runs Weechat that you can connect to from your phone, tablet, or desktop machine. We’ll be using Let’s Encrypt to generate certificates to help keep traffic between our server and clients secure.


We’ll be assuming you’re running NixOS on the server. You can deploy NixOS to a variety of hosting providers. Typeclasses has a detailed tutorial on deploying NixOS to AWS EC2.

Server configuration

NixOS Module

Below, we’ll specify a NixOS module that you can add to the imports list in your server’s nixos configuration file (found in /etc/nixos/configuration.nix).

For example, the default NixOS-on-AWS configuration file looks like this:

  imports = [ <nixpkgs/nixos/modules/virtualisation/amazon-image.nix> ];
  ec2.hvm = true;

And you can add an import to it like this:

  imports = [
  ec2.hvm = true;

Here’s the module we’re going to import. You can save this code in /etc/nixos/weechat.nix, for example, modify it with the correct domain name, and then add weechat.nix to your imports list.

{ pkgs, ...}:

  config = {
    services.nginx = {
      enable = true;
      virtualHosts = {
        # Replace "" with the domain name you'd like to use
        "" = {
          forceSSL = true;
          enableACME = true;
          locations."/weechat" = {
            proxyPass = "";
            proxyWebsockets = true;
            extraConfig = ''
              proxy_read_timeout 4h;
          locations."/" = {
            root = pkgs.glowing-bear;
    services.weechat.enable = true;

You can switch to the new configuration using nixos-rebuild switch.

Once you’ve switched to the new configuration, try running systemctl status weechat to verify that the service is running. You should also be able to navigate to the domain name you specified and see the Glowing Bear interface.

Setting up Weechat

Currently, there’s no declarative configuration for Weechat in NixOS, so to actually configure it you have to stop the system service and run weechat so that you can configure it interactively:

systemctl stop weechat
sudo -u weechat weechat -d /var/lib/weechat

From the Weechat application, you can configure Weechat as described here. We’ll start by setting up the relay so you can do the rest of the configuration through the Glowing Bear itnerface.

Relay Setup

First, we’ll set a passphrase to protect the secrets in the configuration (e.g., passwords):

/secure passphrase this is my secret passphrase

Next, we’ll configure the relay. The port number on the first line here must match the port you specified in your nginx configuration, above.

/relay add irc 8091
/secure set relay YourSecretPasswordGoesHere
/set "${}"

The relay password you set will be used to connect to Weechat from the Glowing Bear interface.

Now you can restart the Weechat service and navigate back to the url you set up earlier. We’ll do the rest of the configuration through Glowing Bear.

Connecting to Glowing Bear

In your web browser, go to the domain you specified in the NixOS module earlier.

In the Hostname field, enter your server’s domain again. Leave the port field blank. Enter your relay password in the WeeChat relay password field.

Check the Encryption box and hit Connect.

Account Setup

You’ll be dropped into a chat interface, but we haven’t connected to any IRC servers yet.

To set up your IRC server connection, run the following commands:

/server add libera
/set irc.server.libera.nicks "NICKNAME"
/set irc.server.libera.username "My user name"
/set irc.server.libera.realname "My real name"
/set irc.server.libera.autoconnect on
/set irc.server.libera.addresses ""
/set irc.server.libera.ssl on
/set irc.server.libera.sasl_username "NICKNAME"
/secure set libera_password xxxxxxx
/set irc.server.libera.sasl_password "${}"
/set irc.server.libera.autojoin "#reflex-frp,#haskell,#nixos"

Mobile Apps

In addition to being able to connect from your browsers, Android users can use the weechat-android application to connect on the go.

iOS users are a little less lucky. There seem to be some client options but they aren’t on the app store and hence require a local build or beta opt-in. Lith has a beta application that iOS users can use via TestFlight.