summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorJoachim F <joachifm@users.noreply.github.com>2017-09-16 12:43:35 +0000
committerGitHub <noreply@github.com>2017-09-16 12:43:35 +0000
commitc0616a323401a8b1c9d8a1581a20494a96fd11f4 (patch)
tree37a4fb97fa27c0f5610f0a865e51e77956fa8062 /nixos/modules
parent9a55f74e43f99842dae07f1390dbaf5a10d86b92 (diff)
parent9c786d82f21db36d0477ca73d3bd667a96b62682 (diff)
downloadnixlib-c0616a323401a8b1c9d8a1581a20494a96fd11f4.tar
nixlib-c0616a323401a8b1c9d8a1581a20494a96fd11f4.tar.gz
nixlib-c0616a323401a8b1c9d8a1581a20494a96fd11f4.tar.bz2
nixlib-c0616a323401a8b1c9d8a1581a20494a96fd11f4.tar.lz
nixlib-c0616a323401a8b1c9d8a1581a20494a96fd11f4.tar.xz
nixlib-c0616a323401a8b1c9d8a1581a20494a96fd11f4.tar.zst
nixlib-c0616a323401a8b1c9d8a1581a20494a96fd11f4.zip
Merge pull request #28892 from ryantm/matterbridge2
matterbridge, modules/matterbridge: init at 1.1.0
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/networking/matterbridge.nix96
2 files changed, 97 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 9ebac8852bb2..eb094f1a9dd6 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -460,6 +460,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";
+        };
+      };
+    })
+  ];
+}
+