mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-21 13:10:33 +00:00
4697f83984
Explain why the assertion fails; the user already knows that it *has* failed.
61 lines
1.4 KiB
Nix
61 lines
1.4 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
{
|
|
###### interface
|
|
|
|
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.
|
|
";
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf config.services.openfire.enable {
|
|
|
|
assertions = singleton
|
|
{ assertion = !(config.services.openfire.usePostgreSQL -> config.services.postgresql.enable);
|
|
message = "OpenFire configured to use PostgreSQL but services.postgresql.enable is not enabled.";
|
|
};
|
|
|
|
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
|
|
for i in ${pkgs.openfire}/conf.inst/*; do
|
|
if ! test -f /etc/openfire/$(basename $i); then
|
|
cp $i /etc/openfire/
|
|
fi
|
|
done
|
|
openfire start
|
|
''; # */
|
|
};
|
|
};
|
|
|
|
}
|