diff --git a/system/options.nix b/system/options.nix index 6afc6ee97fac..da404602880c 100644 --- a/system/options.nix +++ b/system/options.nix @@ -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 diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index 1075bfd6446e..f658e88b90a2 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -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 { diff --git a/upstart-jobs/openfire.nix b/upstart-jobs/openfire.nix index 45338c793e7d..365d34a5b264 100644 --- a/upstart-jobs/openfire.nix +++ b/upstart-jobs/openfire.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 + ''; + }]; + }; }