2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-10-12 17:36:19 +01:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2008-03-03 19:28:10 +00:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
services.openfire = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2020-04-20 19:05:26 +01:00
|
|
|
enable = mkEnableOption "OpenFire XMPP server";
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
usePostgreSQL = mkOption {
|
2020-04-27 08:04:07 +01:00
|
|
|
type = types.bool;
|
2009-10-12 17:36:19 +01:00
|
|
|
default = true;
|
|
|
|
description = "
|
|
|
|
Whether you use PostgreSQL service for your storage back-end.
|
|
|
|
";
|
|
|
|
};
|
2009-03-06 12:27:05 +00:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
};
|
2009-04-30 03:29:58 +01:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
};
|
2009-04-30 03:29:58 +01:00
|
|
|
|
2009-03-06 12:27:05 +00:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
###### implementation
|
2009-03-06 12:27:05 +00:00
|
|
|
|
2013-10-30 17:30:23 +00:00
|
|
|
config = mkIf config.services.openfire.enable {
|
|
|
|
|
|
|
|
assertions = singleton
|
|
|
|
{ assertion = !(config.services.openfire.usePostgreSQL -> config.services.postgresql.enable);
|
2016-12-10 14:39:25 +00:00
|
|
|
message = "OpenFire configured to use PostgreSQL but services.postgresql.enable is not enabled.";
|
2013-10-30 17:30:23 +00:00
|
|
|
};
|
2009-10-12 17:36:19 +01:00
|
|
|
|
2016-01-06 06:50:18 +00:00
|
|
|
systemd.services.openfire = {
|
|
|
|
description = "OpenFire XMPP server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "networking.target" ] ++
|
|
|
|
optional config.services.openfire.usePostgreSQL "postgresql.service";
|
|
|
|
path = with pkgs; [ jre openfire coreutils which gnugrep gawk gnused ];
|
|
|
|
script = ''
|
|
|
|
export HOME=/tmp
|
|
|
|
mkdir /var/log/openfire || true
|
|
|
|
mkdir /etc/openfire || true
|
2016-10-19 16:06:07 +01:00
|
|
|
for i in ${pkgs.openfire}/conf.inst/*; do
|
2016-01-06 06:50:18 +00:00
|
|
|
if ! test -f /etc/openfire/$(basename $i); then
|
|
|
|
cp $i /etc/openfire/
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
openfire start
|
|
|
|
''; # */
|
|
|
|
};
|
2013-10-30 17:30:23 +00:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2008-03-03 19:28:10 +00:00
|
|
|
}
|