nixos/mattermost: use database config if set to immutable
This commit is contained in:
parent
366be2ea32
commit
346a6ce265
@ -10,12 +10,14 @@ let
|
|||||||
(readFile "${pkgs.mattermost}/config/config.json")
|
(readFile "${pkgs.mattermost}/config/config.json")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
database = "postgres://${cfg.localDatabaseUser}:${cfg.localDatabasePassword}@localhost:5432/${cfg.localDatabaseName}?sslmode=disable&connect_timeout=10";
|
||||||
|
|
||||||
mattermostConf = foldl recursiveUpdate defaultConfig
|
mattermostConf = foldl recursiveUpdate defaultConfig
|
||||||
[ { ServiceSettings.SiteURL = cfg.siteUrl;
|
[ { ServiceSettings.SiteURL = cfg.siteUrl;
|
||||||
ServiceSettings.ListenAddress = cfg.listenAddress;
|
ServiceSettings.ListenAddress = cfg.listenAddress;
|
||||||
TeamSettings.SiteName = cfg.siteName;
|
TeamSettings.SiteName = cfg.siteName;
|
||||||
SqlSettings.DriverName = "postgres";
|
SqlSettings.DriverName = "postgres";
|
||||||
SqlSettings.DataSource = "postgres://${cfg.localDatabaseUser}:${cfg.localDatabasePassword}@localhost:5432/${cfg.localDatabaseName}?sslmode=disable&connect_timeout=10";
|
SqlSettings.DataSource = database;
|
||||||
}
|
}
|
||||||
cfg.extraConfig
|
cfg.extraConfig
|
||||||
];
|
];
|
||||||
@ -177,7 +179,9 @@ in
|
|||||||
mkdir -p ${cfg.statePath}/{data,config,logs}
|
mkdir -p ${cfg.statePath}/{data,config,logs}
|
||||||
ln -sf ${pkgs.mattermost}/{bin,fonts,i18n,templates,client} ${cfg.statePath}
|
ln -sf ${pkgs.mattermost}/{bin,fonts,i18n,templates,client} ${cfg.statePath}
|
||||||
'' + lib.optionalString (!cfg.mutableConfig) ''
|
'' + lib.optionalString (!cfg.mutableConfig) ''
|
||||||
ln -sf ${mattermostConfJSON} ${cfg.statePath}/config/config.json
|
rm -f ${cfg.statePath}/config/config.json
|
||||||
|
cp ${mattermostConfJSON} ${cfg.statePath}/config/config.json
|
||||||
|
${pkgs.mattermost}/bin/mattermost config migrate ${cfg.statePath}/config/config.json ${database}
|
||||||
'' + lib.optionalString cfg.mutableConfig ''
|
'' + lib.optionalString cfg.mutableConfig ''
|
||||||
if ! test -e "${cfg.statePath}/config/.initial-created"; then
|
if ! test -e "${cfg.statePath}/config/.initial-created"; then
|
||||||
rm -f ${cfg.statePath}/config/config.json
|
rm -f ${cfg.statePath}/config/config.json
|
||||||
@ -203,7 +207,8 @@ in
|
|||||||
PermissionsStartOnly = true;
|
PermissionsStartOnly = true;
|
||||||
User = cfg.user;
|
User = cfg.user;
|
||||||
Group = cfg.group;
|
Group = cfg.group;
|
||||||
ExecStart = "${pkgs.mattermost}/bin/mattermost";
|
ExecStart = "${pkgs.mattermost}/bin/mattermost" +
|
||||||
|
(lib.optionalString (!cfg.mutableConfig) " -c ${database}");
|
||||||
WorkingDirectory = "${cfg.statePath}";
|
WorkingDirectory = "${cfg.statePath}";
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
RestartSec = "10";
|
RestartSec = "10";
|
||||||
@ -229,4 +234,3 @@ in
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user