Convert "openfire" (problem with assertion)

svn path=/nixos/branches/fix-style/; revision=14391
This commit is contained in:
Marc Weber 2009-03-06 12:27:05 +00:00
parent 8e840a7aa4
commit e5fd3f271e
3 changed files with 61 additions and 44 deletions

@ -479,22 +479,6 @@ in
};
openfire = {
enable = mkOption {
default = false;
description = "
Whether to enable OpenFire XMPP server.
";
};
usePostgreSQL = mkOption {
default = true;
description = "
Whether you use PostgreSQL service for your storage back-end.
";
};
};
postfix = {
enable = mkOption {
default = false;
@ -799,6 +783,7 @@ in
(import ../upstart-jobs/xfs.nix)
(import ../upstart-jobs/mysql.nix)
(import ../upstart-jobs/postgresql.nix)
(import ../upstart-jobs/openfire.nix)
# nix
(import ../upstart-jobs/nix.nix) # nix options and daemon

@ -131,12 +131,6 @@ let
inherit config;
})
# OpenFire XMPP server
++ optional config.services.openfire.enable
(import ../upstart-jobs/openfire.nix {
inherit config pkgs;
})
# Postfix mail server.
++ optional config.services.postfix.enable
(import ../upstart-jobs/postfix.nix {

@ -1,7 +1,36 @@
{pkgs, config}:
{pkgs, config, ...}:
assert config.services.openfire.usePostgreSQL -> config.services.postgresql.enable;
###### interface
let
inherit (pkgs.lib) mkOption mkIf;
options = {
services = {
openfire = {
enable = mkOption {
default = false;
description = "
Whether to enable OpenFire XMPP server.
";
};
usePostgreSQL = mkOption {
default = true;
description = "
Whether you use PostgreSQL service for your storage back-end.
";
};
};
};
};
in
###### implementation
# FIXME (see xfs)
# if (!(config.services.openfire.usePostgreSQL -> config.services.postgresql.enable)) then throw "openfire assertion failed" else
let
inherit (pkgs) jre openfire coreutils which gnugrep gawk gnused;
startDependency = if config.services.openfire.usePostgreSQL then
"postgresql"
else
@ -10,26 +39,35 @@ let
else
"network-interfaces";
in
with pkgs;
{
name = "openfire";
job = ''
description "OpenFire XMPP server"
start on ${startDependency}/started
stop on shutdown
mkIf config.services.openfire.enable {
require = [
options
];
script
export PATH=${jre}/bin:${openfire}/bin:${coreutils}/bin:${which}/bin:${gnugrep}/bin:${gawk}/bin:${gnused}/bin
export HOME=/tmp
mkdir /var/log/openfire || true
mkdir /etc/openfire || true
for i in ${openfire}/conf.inst/*; do
if ! test -f /etc/openfire/$(basename $i); then
cp $i /etc/openfire/
fi
done
openfire start
end script
'';
services = {
extraJobs = [{
name = "openfire";
job = ''
description "OpenFire XMPP server"
start on ${startDependency}/started
stop on shutdown
script
export PATH=${jre}/bin:${openfire}/bin:${coreutils}/bin:${which}/bin:${gnugrep}/bin:${gawk}/bin:${gnused}/bin
export HOME=/tmp
mkdir /var/log/openfire || true
mkdir /etc/openfire || true
for i in ${openfire}/conf.inst/*; do
if ! test -f /etc/openfire/$(basename $i); then
cp $i /etc/openfire/
fi
done
openfire start
end script
'';
}];
};
}