nixpkgs/nixos/modules/services/networking/matterbridge.nix
Silvan Mosberger 667d42c00d treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev 57b193d8dd
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:27:17 +01:00

124 lines
3.3 KiB
Nix

{
options,
config,
pkgs,
lib,
...
}:
let
cfg = config.services.matterbridge;
matterbridgeConfToml =
if cfg.configPath == null then
pkgs.writeText "matterbridge.toml" (cfg.configFile)
else
cfg.configPath;
in
{
options = {
services.matterbridge = {
enable = lib.mkEnableOption "Matterbridge chat platform bridge";
package = lib.mkPackageOption pkgs "matterbridge" { };
configPath = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
example = "/etc/nixos/matterbridge.toml";
description = ''
The path to the matterbridge configuration file.
'';
};
configFile = lib.mkOption {
type = lib.types.str;
example = ''
# 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]
[irc.libera]
Server="irc.libera.chat:6667"
Nick="matterbot"
[mattermost]
[mattermost.work]
# Do not prefix it with http:// or https://
Server="yourmattermostserver.domain"
Team="yourteam"
Login="yourlogin"
Password="yourpass"
PrefixMessagesWithNick=true
[[gateway]]
name="gateway1"
enable=true
[[gateway.inout]]
account="irc.libera"
channel="#testing"
[[gateway.inout]]
account="mattermost.work"
channel="off-topic"
'';
description = ''
WARNING: THIS IS INSECURE, as your password will end up in
{file}`/nix/store`, thus publicly readable. Use
`services.matterbridge.configPath` instead.
The matterbridge configuration file in the TOML file format.
'';
};
user = lib.mkOption {
type = lib.types.str;
default = "matterbridge";
description = ''
User which runs the matterbridge service.
'';
};
group = lib.mkOption {
type = lib.types.str;
default = "matterbridge";
description = ''
Group which runs the matterbridge service.
'';
};
};
};
config = lib.mkIf cfg.enable {
warnings = lib.optional options.services.matterbridge.configFile.isDefined "The option services.matterbridge.configFile is insecure and should be replaced with services.matterbridge.configPath";
users.users = lib.optionalAttrs (cfg.user == "matterbridge") {
matterbridge = {
group = "matterbridge";
isSystemUser = true;
};
};
users.groups = lib.optionalAttrs (cfg.group == "matterbridge") {
matterbridge = { };
};
systemd.services.matterbridge = {
description = "Matterbridge chat platform bridge";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
User = cfg.user;
Group = cfg.group;
ExecStart = "${cfg.package}/bin/matterbridge -conf ${matterbridgeConfToml}";
Restart = "always";
RestartSec = "10";
};
};
};
}