diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index a46448b94378..b9537e9820ef 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -458,6 +458,7 @@ ./services/networking/lldpd.nix ./services/networking/logmein-hamachi.nix ./services/networking/mailpile.nix + ./services/networking/matterbridge.nix ./services/networking/mjpg-streamer.nix ./services/networking/minidlna.nix ./services/networking/miniupnpd.nix diff --git a/nixos/modules/services/networking/matterbridge.nix b/nixos/modules/services/networking/matterbridge.nix new file mode 100644 index 000000000000..5526e2ba23ac --- /dev/null +++ b/nixos/modules/services/networking/matterbridge.nix @@ -0,0 +1,96 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + + cfg = config.services.matterbridge; + + matterbridgeConfToml = pkgs.writeText "matterbridge.toml" (cfg.configFile); + +in + +{ + options = { + services.matterbridge = { + enable = mkEnableOption "Matterbridge chat platform bridge"; + + configFile = mkOption { + type = types.str; + example = '' + #WARNING: as this file contains credentials, be sure to set correct file permissions [irc] + [irc.freenode] + Server="irc.freenode.net:6667" + Nick="matterbot" + + [mattermost] + [mattermost.work] + #do not prefix it wit http:// or https:// + Server="yourmattermostserver.domain" + Team="yourteam" + Login="yourlogin" + Password="yourpass" + PrefixMessagesWithNick=true + + [[gateway]] + name="gateway1" + enable=true + [[gateway.inout]] + account="irc.freenode" + channel="#testing" + + [[gateway.inout]] + account="mattermost.work" + channel="off-topic" + ''; + description = '' + The matterbridge configuration file in the TOML file format. + ''; + }; + user = mkOption { + type = types.str; + default = "matterbridge"; + description = '' + User which runs the matterbridge service. + ''; + }; + + group = mkOption { + type = types.str; + default = "matterbridge"; + description = '' + Group which runs the matterbridge service. + ''; + }; + }; + }; + + config = mkMerge [ + (mkIf cfg.enable { + + users.extraUsers = mkIf (cfg.user == "matterbridge") [ + { name = "matterbridge"; + group = "matterbridge"; + } ]; + + users.extraGroups = mkIf (cfg.group == "matterbridge") [ + { name = "matterbridge"; + } ]; + + systemd.services.matterbridge = { + description = "Matterbridge chat platform bridge"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + + serviceConfig = { + User = cfg.user; + Group = cfg.group; + ExecStart = "${pkgs.matterbridge.bin}/bin/matterbridge -conf ${matterbridgeConfToml}"; + Restart = "always"; + RestartSec = "10"; + }; + }; + }) + ]; +} + diff --git a/pkgs/servers/matterbridge/default.nix b/pkgs/servers/matterbridge/default.nix new file mode 100644 index 000000000000..ee895ba3fe4b --- /dev/null +++ b/pkgs/servers/matterbridge/default.nix @@ -0,0 +1,21 @@ +{ stdenv, buildGoPackage, fetchurl }: + +buildGoPackage rec { + name = "matterbridge-${version}"; + version = "1.1.0"; + + goPackagePath = "github.com/42wim/matterbridge"; + + src = fetchurl { + url = "https://github.com/42wim/matterbridge/archive/v${version}.tar.gz"; + sha256 = "0nn3929wyjdpkk8azp6wd6mkcg8h0jb1fjxm6jmb74xvdknrzv3k"; + }; + + meta = with stdenv.lib; { + description = "Simple bridge between Mattermost, IRC, XMPP, Gitter, Slack, Discord, Telegram, Rocket.Chat, Hipchat(via xmpp), Matrix and Steam"; + homepage = https://github.com/42wim/matterbridge; + license = with licenses; [ asl20 ]; + maintainers = with maintainers; [ ryantm ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0ca1dff970b7..2f6314d2cd1e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11335,6 +11335,7 @@ with pkgs; mattermost = callPackage ../servers/mattermost { }; matterircd = callPackage ../servers/mattermost/matterircd.nix { }; + matterbridge = callPackage ../servers/matterbridge { }; mediatomb = callPackage ../servers/mediatomb { };