2018-04-24 22:37:25 +00:00
|
|
|
{ options, config, pkgs, lib, ... }:
|
2017-09-02 04:21:26 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.matterbridge;
|
|
|
|
|
2018-04-24 22:37:25 +00:00
|
|
|
matterbridgeConfToml =
|
|
|
|
if cfg.configPath == null then
|
|
|
|
pkgs.writeText "matterbridge.toml" (cfg.configFile)
|
|
|
|
else
|
|
|
|
cfg.configPath;
|
2017-09-02 04:21:26 +00:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.matterbridge = {
|
|
|
|
enable = mkEnableOption (lib.mdDoc "Matterbridge chat platform bridge");
|
|
|
|
|
2018-04-24 22:37:25 +00:00
|
|
|
configPath = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
|
|
|
example = "/etc/nixos/matterbridge.toml";
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
The path to the matterbridge configuration file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-09-02 04:21:26 +00:00
|
|
|
configFile = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = ''
|
2018-04-24 22:37:25 +00:00
|
|
|
# WARNING: as this file contains credentials, do not use this option!
|
|
|
|
# It is kept only for backwards compatibility, and would cause your
|
|
|
|
# credentials to be in the nix-store, thus with the world-readable
|
|
|
|
# permission bits.
|
|
|
|
# Use services.matterbridge.configPath instead.
|
|
|
|
|
|
|
|
[irc]
|
2021-06-19 16:23:15 +00:00
|
|
|
[irc.libera]
|
|
|
|
Server="irc.libera.chat:6667"
|
2017-09-02 04:21:26 +00:00
|
|
|
Nick="matterbot"
|
|
|
|
|
|
|
|
[mattermost]
|
|
|
|
[mattermost.work]
|
2018-04-24 22:37:25 +00:00
|
|
|
# Do not prefix it with http:// or https://
|
2017-09-02 04:21:26 +00:00
|
|
|
Server="yourmattermostserver.domain"
|
|
|
|
Team="yourteam"
|
|
|
|
Login="yourlogin"
|
|
|
|
Password="yourpass"
|
|
|
|
PrefixMessagesWithNick=true
|
|
|
|
|
|
|
|
[[gateway]]
|
|
|
|
name="gateway1"
|
|
|
|
enable=true
|
|
|
|
[[gateway.inout]]
|
2021-06-19 16:23:15 +00:00
|
|
|
account="irc.libera"
|
2017-09-02 04:21:26 +00:00
|
|
|
channel="#testing"
|
|
|
|
|
|
|
|
[[gateway.inout]]
|
|
|
|
account="mattermost.work"
|
|
|
|
channel="off-topic"
|
|
|
|
'';
|
|
|
|
description = lib.mdDoc ''
|
2018-04-24 22:37:25 +00:00
|
|
|
WARNING: THIS IS INSECURE, as your password will end up in
|
|
|
|
{file}`/nix/store`, thus publicly readable. Use
|
|
|
|
`services.matterbridge.configPath` instead.
|
|
|
|
|
2017-09-02 04:21:26 +00:00
|
|
|
The matterbridge configuration file in the TOML file format.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "matterbridge";
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
User which runs the matterbridge service.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "matterbridge";
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Group which runs the matterbridge service.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-04-24 22:37:25 +00:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
warnings = optional options.services.matterbridge.configFile.isDefined
|
|
|
|
"The option services.matterbridge.configFile is insecure and should be replaced with services.matterbridge.configPath";
|
|
|
|
|
2019-09-14 17:51:29 +00:00
|
|
|
users.users = optionalAttrs (cfg.user == "matterbridge")
|
|
|
|
{ matterbridge = {
|
|
|
|
group = "matterbridge";
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
2018-04-24 22:37:25 +00:00
|
|
|
};
|
|
|
|
|
2019-09-14 17:51:29 +00:00
|
|
|
users.groups = optionalAttrs (cfg.group == "matterbridge")
|
|
|
|
{ matterbridge = { };
|
2017-09-02 04:21:26 +00:00
|
|
|
};
|
|
|
|
|
2018-04-24 22:37:25 +00:00
|
|
|
systemd.services.matterbridge = {
|
|
|
|
description = "Matterbridge chat platform bridge";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
2020-01-10 20:00:43 +00:00
|
|
|
ExecStart = "${pkgs.matterbridge}/bin/matterbridge -conf ${matterbridgeConfToml}";
|
2018-04-24 22:37:25 +00:00
|
|
|
Restart = "always";
|
|
|
|
RestartSec = "10";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|