{ config, pkgs, mod, ... }: let inherit (pkgs) abduco dvtm-git; weechat = pkgs.weechat.override { configure = { availablePlugins, ... }: { plugins = builtins.attrValues (availablePlugins // { python = availablePlugins.python.withPackages (_: [ pkgs.weechat-matrix.weechat-matrix ]); }); scripts = with pkgs; [ weechat-matrix.weechat-matrix ]; }; }; relayDomain = "weechat.${config.networking.privateDomain}"; in { users.users.weechat = { isSystemUser = true; home = "/var/lib/weechat"; createHome = true; openssh.authorizedKeys.keyFiles = [ (mod /assets/foo.pub) ]; packages = [ abduco ]; files.".profile".text = '' if [ -n "$SSH_TTY" ]; then exec abduco -a irc fi ''; shell = pkgs.bashInteractive; }; services.nginx.virtualHosts.${relayDomain} = { listenPrivate = true; locations."/weechat" = { proxyPass = "http://127.0.0.1:9000/weechat"; extraConfig = '' proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; ''; }; }; systemd.services.weechat = { path = with pkgs; [ abduco weechat ]; script = '' abduco -n irc weechat -d ${config.users.users.weechat.home} ''; environment = { TERM = "rxvt-unicode-256color"; TERMINFO = "${pkgs.rxvt_unicode.terminfo}/share/terminfo"; NCURSES_NO_UTF8_ACS = "1"; }; serviceConfig = { Type = "forking"; User = "weechat"; WorkingDirectory = config.users.users.weechat.home; Restart = "always"; RestartSec = 3; }; restartIfChanged = false; wantedBy = [ "multi-user.target" ]; wants = [ "network-online.target" ]; after = [ "network-online.target" ]; }; }