aboutsummaryrefslogblamecommitdiff
path: root/nixops/modules/irc/default.nix
blob: 37cb53b881429533666894d25ef456ea47951acb (plain) (tree)






































































                                                                              

                                                  

                                                                        
         
 



























                                                   
{ lib, pkgs, config, myconfig, mylibs, ... }:
let
  bitlbee-mastodon = with pkgs; stdenv.mkDerivation rec {
    name = "bitlbee-mastodon-${version}";
    version = "v1.4.2";

    src = fetchFromGitHub {
      rev = version;
      owner = "kensanata";
      repo = "bitlbee-mastodon";
      sha256 = "04rakgr1pfsg1vhfwlfbggbzw249j7dmk88xrsnf3n84c5ccdyas";
    };

    nativeBuildInputs = [ autoreconfHook pkgconfig ];
    buildInputs = [ bitlbee glib ];

    preConfigure = ''
      export BITLBEE_PLUGINDIR=$out/lib/bitlbee
      ./autogen.sh
    '';

    meta = {
      description = "Bitlbee plugin for Mastodon";

      homepage = https://github.com/kensanata/bitlbee-mastodon;
      license = lib.licenses.gpl2Plus;
      platforms = stdenv.lib.platforms.linux;
    };
  };
  bitlbee-discord = pkgs.bitlbee-discord.overrideAttrs(old: rec {
    name = "bitlbee-discord-${version}";
    version = "0.4.2";

    src = pkgs.fetchFromGitHub {
      rev = version;
      owner = "sm00th";
      repo = "bitlbee-discord";
      sha256 = "02pigk2vbz0jdz11f96sygdvp1j762yjn62h124fkcsc070g7a2f";
    };
  });
  bitlbee-facebook = pkgs.bitlbee-facebook.overrideAttrs(old: rec {
    name = "bitlbee-facebook-${version}";
    version = "1.2.0";

    src = pkgs.fetchFromGitHub {
      rev = "v${version}";
      owner = "bitlbee";
      repo = "bitlbee-facebook";
      sha256 = "11068zhb1v55b1x0nhjc4f3p0glccxpcyk5c1630hfdzkj7vyqhn";
    };
  });
in
{
  options = {
    services.irc.enable = lib.mkOption {
      type = lib.types.bool;
      default = false;
      description = ''
        Whether to enable irc stuff.
      '';
    };
  };

  config = lib.mkIf config.services.irc.enable {
    security.acme.certs."irc" = config.services.myCertificates.certConfig // {
      domain = "irc.immae.eu";
      postRun = ''
        systemctl restart stunnel.service
      '';
    };

    nixpkgs.overlays = [ (self: super: rec {
      bitlbee = super.bitlbee.overrideAttrs(old: {
        patches = (old.patches or []) ++ [ ./bitlbee_long_nicks.patch ];
      });
    }) ];

    networking.firewall.allowedTCPPorts = [ 6697 ];
    services.bitlbee = {
      enable = true;
      authMode = "Registered";
      libpurple_plugins = [
        pkgs.purple-hangouts
        pkgs.purple-matrix
      ];
      plugins = [
        bitlbee-mastodon
        bitlbee-facebook
        bitlbee-discord
        pkgs.bitlbee-steam
      ];
    };

    services.stunnel = {
      enable = true;
      servers = {
        bitlbee = {
          accept = 6697;
          connect = 6667;
          cert = "/var/lib/acme/irc/full.pem";
        };
      };
    };
  };
}