2018-04-25 00:37:25 +02:00
|
|
|
{ options, config, pkgs, lib, ... }:
|
2017-09-02 06:21:26 +02:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.matterbridge;
|
|
|
|
|
2018-04-25 00:37:25 +02:00
|
|
|
matterbridgeConfToml =
|
|
|
|
if cfg.configPath == null then
|
|
|
|
pkgs.writeText "matterbridge.toml" (cfg.configFile)
|
|
|
|
else
|
|
|
|
cfg.configPath;
|
2017-09-02 06:21:26 +02:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.matterbridge = {
|
|
|
|
enable = mkEnableOption "Matterbridge chat platform bridge";
|
|
|
|
|
2018-04-25 00:37:25 +02:00
|
|
|
configPath = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
|
|
|
example = "/etc/nixos/matterbridge.toml";
|
|
|
|
description = ''
|
|
|
|
The path to the matterbridge configuration file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-09-02 06:21:26 +02:00
|
|
|
configFile = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = ''
|
2018-04-25 00:37:25 +02: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]
|
2017-09-02 06:21:26 +02:00
|
|
|
[irc.freenode]
|
|
|
|
Server="irc.freenode.net:6667"
|
|
|
|
Nick="matterbot"
|
|
|
|
|
|
|
|
[mattermost]
|
|
|
|
[mattermost.work]
|
2018-04-25 00:37:25 +02:00
|
|
|
# Do not prefix it with http:// or https://
|
2017-09-02 06:21:26 +02:00
|
|
|
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 = ''
|
2018-04-25 00:37:25 +02:00
|
|
|
WARNING: THIS IS INSECURE, as your password will end up in
|
|
|
|
<filename>/nix/store</filename>, thus publicly readable. Use
|
|
|
|
<literal>services.matterbridge.configPath</literal> instead.
|
|
|
|
|
2017-09-02 06:21:26 +02:00
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-04-25 00:37:25 +02: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";
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.users = optional (cfg.user == "matterbridge")
|
2018-04-25 00:37:25 +02:00
|
|
|
{ name = "matterbridge";
|
|
|
|
group = "matterbridge";
|
|
|
|
};
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.groups = optional (cfg.group == "matterbridge")
|
2018-04-25 00:37:25 +02:00
|
|
|
{ name = "matterbridge";
|
2017-09-02 06:21:26 +02:00
|
|
|
};
|
|
|
|
|
2018-04-25 00:37:25 +02:00
|
|
|
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";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|