···
1
+
# Mattermost {#sec-mattermost}
3
+
The NixOS Mattermost module lets you build [Mattermost](https://mattermost.com)
4
+
instances for collaboration over chat, optionally with custom builds of plugins
5
+
specific to your instance.
7
+
To enable Mattermost using Postgres, use a config like this:
11
+
services.mattermost = {
14
+
# You can change this if you are reverse proxying.
18
+
# Allow modifications to the config from Mattermost.
19
+
mutableConfig = true;
21
+
# Override modifications to the config with your NixOS config.
22
+
preferNixConfig = true;
25
+
# Enable control with the `mmctl` socket.
28
+
# Exporting the control socket will add `mmctl` to your PATH, and export
29
+
# MMCTL_LOCAL_SOCKET_PATH systemwide. Otherwise, you can get the socket
30
+
# path out of `config.mattermost.socket.path` and set it manually.
34
+
# For example, to disable auto-installation of prepackaged plugins.
35
+
settings.PluginSettings.AutomaticPrepackagedPlugins = false;
40
+
As of NixOS 25.05, Mattermost uses peer authentication with Postgres or
41
+
MySQL by default. If you previously used password auth on localhost,
42
+
this will automatically be configured if your `stateVersion` is set to at least
45
+
## Using the Mattermost derivation {#sec-mattermost-derivation}
47
+
The nixpkgs `mattermost` derivation runs the entire test suite during the
48
+
`checkPhase`. This test suite is run with a live MySQL and Postgres database
49
+
instance in the sandbox. If you are building Mattermost, this can take a while,
50
+
especially if it is building on a resource-constrained system.
52
+
The following passthrus are designed to assist with enabling or disabling
55
+
- `mattermost.withTests`
56
+
- `mattermost.withoutTests`
58
+
The default (`mattermost`) is an alias for `mattermost.withTests`.
60
+
## Using Mattermost plugins {#sec-mattermost-plugins}
62
+
You can configure Mattermost plugins by either using prebuilt binaries or by
63
+
building your own. We test building and using plugins in the NixOS test suite.
65
+
Mattermost plugins are tarballs containing a system-specific statically linked
66
+
Go binary and webapp resources.
68
+
Here is an example with a prebuilt plugin tarball:
72
+
services.mattermost = {
73
+
plugins = with pkgs; [
77
+
* https://github.com/mattermost/mattermost-plugin-todo/releases/tag/v0.7.1
80
+
# Note: Don't unpack the tarball; the NixOS module will repack it for you.
81
+
url = "https://github.com/mattermost-community/mattermost-plugin-todo/releases/download/v0.7.1/com.mattermost.plugin-todo-0.7.1.tar.gz";
82
+
hash = "sha256-P+Z66vqE7FRmc2kTZw9FyU5YdLLbVlcJf11QCbfeJ84=";
89
+
Once the plugin is installed and the config rebuilt, you can enable this plugin
90
+
in the System Console.
92
+
## Building Mattermost plugins {#sec-mattermost-plugins-build}
94
+
The `mattermost` derivation includes the `buildPlugin` passthru for building
95
+
plugins that use the "standard" Mattermost plugin build template at
96
+
[mattermost-plugin-demo](https://github.com/mattermost/mattermost-plugin-demo).
98
+
Since this is a "de facto" standard for building Mattermost plugins that makes
99
+
assumptions about the build environment, the `buildPlugin` helper tries to fit
100
+
these assumptions the best it can.
102
+
Here is how to build the above Todo plugin. Note that we rely on
103
+
package-lock.json being assembled correctly, so must use a version where it is!
104
+
If there is no lockfile or the lockfile is incorrect, Nix cannot fetch NPM build
105
+
and runtime dependencies for a sandbox build.
109
+
services.mattermost = {
110
+
plugins = with pkgs; [
111
+
(mattermost.buildPlugin {
112
+
pname = "mattermost-plugin-todo";
113
+
version = "0.8-pre";
114
+
src = fetchFromGitHub {
115
+
owner = "mattermost-community";
116
+
repo = "mattermost-plugin-todo";
117
+
# 0.7.1 didn't work, seems to use an older set of node dependencies.
118
+
rev = "f25dc91ea401c9f0dcd4abcebaff10eb8b9836e5";
119
+
hash = "sha256-OM+m4rTqVtolvL5tUE8RKfclqzoe0Y38jLU60Pz7+HI=";
121
+
vendorHash = "sha256-5KpechSp3z/Nq713PXYruyNxveo6CwrCSKf2JaErbgg=";
122
+
npmDepsHash = "sha256-o2UOEkwb8Vx2lDWayNYgng0GXvmS6lp/ExfOq3peyMY=";
123
+
extraGoModuleAttrs = {
124
+
npmFlags = [ "--legacy-peer-deps" ];
132
+
See `pkgs/by-name/ma/mattermost/build-plugin.nix` for all the options.
133
+
As in the previous example, once the plugin is installed and the config rebuilt,
134
+
you can enable this plugin in the System Console.