2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-10-12 18:36:19 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2008-03-03 20:28:10 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
services.openfire = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2020-04-20 20:05:26 +02:00
|
|
|
enable = mkEnableOption "OpenFire XMPP server";
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
usePostgreSQL = mkOption {
|
2020-04-27 09:04:07 +02:00
|
|
|
type = types.bool;
|
2009-10-12 18:36:19 +02:00
|
|
|
default = true;
|
|
|
|
description = "
|
|
|
|
Whether you use PostgreSQL service for your storage back-end.
|
|
|
|
";
|
|
|
|
};
|
2009-03-06 13:27:05 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
};
|
2009-04-30 04:29:58 +02:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
};
|
2009-04-30 04:29:58 +02:00
|
|
|
|
2009-03-06 13:27:05 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
###### implementation
|
2009-03-06 13:27:05 +01:00
|
|
|
|
2013-10-30 18:30:23 +01:00
|
|
|
config = mkIf config.services.openfire.enable {
|
|
|
|
|
|
|
|
assertions = singleton
|
|
|
|
{ assertion = !(config.services.openfire.usePostgreSQL -> config.services.postgresql.enable);
|
2016-12-10 15:39:25 +01:00
|
|
|
message = "OpenFire configured to use PostgreSQL but services.postgresql.enable is not enabled.";
|
2013-10-30 18:30:23 +01:00
|
|
|
};
|
2009-10-12 18:36:19 +02:00
|
|
|
|
2016-01-06 07:50:18 +01: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 17:06:07 +02:00
|
|
|
for i in ${pkgs.openfire}/conf.inst/*; do
|
2016-01-06 07:50:18 +01:00
|
|
|
if ! test -f /etc/openfire/$(basename $i); then
|
|
|
|
cp $i /etc/openfire/
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
openfire start
|
|
|
|
''; # */
|
|
|
|
};
|
2013-10-30 18:30:23 +01:00
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2008-03-03 20:28:10 +01:00
|
|
|
}
|