feat(mattermost): persist state directories

This commit is contained in:
Mohammad Rafiq 2025-06-12 13:58:44 +08:00
parent bd03642216
commit 3b57194a56
No known key found for this signature in database

View file

@ -1,11 +1,12 @@
{ { config, lib, ... }:
config,
lib,
pkgs,
...
}:
let let
cfg = config.server.web-apps.mattermost; cfg = config.server.web-apps.mattermost;
upstreamCfg = config.services.mattermost;
mkDir = directory: {
inherit directory;
inherit (upstreamCfg) user group;
mode = "0750";
};
in in
{ {
options.server.web-apps.mattermost = { options.server.web-apps.mattermost = {
@ -30,6 +31,11 @@ in
message = "You must enable a local instance of postgresql."; message = "You must enable a local instance of postgresql.";
} }
]; ];
environment.persistence."/persist".directories = [
(mkDir cfg.configDir)
(mkDir cfg.logDir)
(mkDir cfg.dataDir)
];
networking.firewall.allowedTCPPorts = lib.singleton cfg.port; networking.firewall.allowedTCPPorts = lib.singleton cfg.port;
services.mattermost = { services.mattermost = {
enable = true; enable = true;
@ -44,9 +50,9 @@ in
siteUrl = "https://${cfg.url}"; siteUrl = "https://${cfg.url}";
}; };
services.postgresql = { services.postgresql = {
ensureDatabases = lib.singleton config.services.mattermost.database.name; ensureDatabases = lib.singleton upstreamCfg.database.name;
ensureUsers = lib.singleton { ensureUsers = lib.singleton {
name = config.services.mattermost.database.user; name = upstreamCfg.database.user;
ensureDBOwnership = true; ensureDBOwnership = true;
}; };
}; };