2009-10-12 16:36:19 +00:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
2008-03-03 19:28:10 +00:00
|
|
|
|
|
|
|
let
|
2009-03-06 12:27:05 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
inherit (pkgs) jre openfire coreutils which gnugrep gawk gnused;
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2012-03-04 12:58:18 +00:00
|
|
|
extraStartDependency =
|
|
|
|
if config.services.openfire.usePostgreSQL then "and started postgresql" else "";
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-03-06 12:27:05 +00:00
|
|
|
in
|
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
{
|
2009-03-06 12:27:05 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
services.openfire = {
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
|
|
|
Whether to enable OpenFire XMPP server.
|
|
|
|
";
|
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
usePostgreSQL = mkOption {
|
|
|
|
default = true;
|
|
|
|
description = "
|
|
|
|
Whether you use PostgreSQL service for your storage back-end.
|
|
|
|
";
|
|
|
|
};
|
2009-03-06 12:27:05 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
2009-04-30 02:29:58 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
2009-04-30 02:29:58 +00:00
|
|
|
|
2009-03-06 12:27:05 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
###### implementation
|
2009-03-06 12:27:05 +00:00
|
|
|
|
2011-03-30 17:52:34 +00:00
|
|
|
config = mkIf config.services.openfire.enable (
|
|
|
|
mkAssert (!(config.services.openfire.usePostgreSQL -> config.services.postgresql.enable)) "
|
|
|
|
openfire assertion failed
|
|
|
|
" {
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2009-10-12 18:09:34 +00:00
|
|
|
jobs.openfire =
|
2009-10-12 16:36:19 +00:00
|
|
|
{ description = "OpenFire XMPP server";
|
|
|
|
|
2012-03-04 18:44:42 +00:00
|
|
|
startOn = "started networking ${extraStartDependency}";
|
2009-03-06 12:27:05 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
script =
|
|
|
|
''
|
2009-03-06 12:27:05 +00:00
|
|
|
export PATH=${jre}/bin:${openfire}/bin:${coreutils}/bin:${which}/bin:${gnugrep}/bin:${gawk}/bin:${gnused}/bin
|
|
|
|
export HOME=/tmp
|
2011-09-14 18:20:50 +00:00
|
|
|
mkdir /var/log/openfire || true
|
|
|
|
mkdir /etc/openfire || true
|
2009-03-06 12:27:05 +00:00
|
|
|
for i in ${openfire}/conf.inst/*; do
|
|
|
|
if ! test -f /etc/openfire/$(basename $i); then
|
|
|
|
cp $i /etc/openfire/
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
openfire start
|
2009-10-12 16:36:19 +00:00
|
|
|
''; # */
|
|
|
|
};
|
|
|
|
|
2011-03-30 17:52:34 +00:00
|
|
|
});
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2008-03-03 19:28:10 +00:00
|
|
|
}
|