anchor.diff:  
               if ! test -d ${cfg.spoolDir}
               then
  -	        initialize=1
  +                initialize=1
                   cp -av ${pkgs.ejabberd}/var/lib/ejabberd /var/lib
               fi
  -            
  +
               if ! test -d ${cfg.confDir}
  -	    then
  -		mkdir -p ${cfg.confDir}
  -	        cp ${pkgs.ejabberd}/etc/ejabberd/* ${cfg.confDir}
  -	        sed -e 's|{hosts, \["localhost"\]}.|{hosts, \[${cfg.virtualHosts}\]}.|' ${pkgs.ejabberd}/etc/ejabberd/ejabberd.cfg > ${cfg.confDir}/ejabberd.cfg
  -	    fi
  -	    
  -	    ejabberdctl --config-dir ${cfg.confDir} --logs ${cfg.logsDir} --spool ${cfg.spoolDir} start
  -	    
  -	    ${if cfg.loadDumps == [] then "" else
  -	      ''	      
  -	        if [ "$initialize" = "1" ]
  -	        then
  -	            # Wait until the ejabberd server is available for use
  +            then
  +                mkdir -p ${cfg.confDir}
  +                cp ${pkgs.ejabberd}/etc/ejabberd/* ${cfg.confDir}
  +                sed -e 's|{hosts, \["localhost"\]}.|{hosts, \[${cfg.virtualHosts}\]}.|' ${pkgs.ejabberd}/etc/ejabberd/ejabberd.cfg > ${cfg.confDir}/ejabberd.cfg
  +            fi
  +
  +            ejabberdctl --config-dir ${cfg.confDir} --logs ${cfg.logsDir} --spool ${cfg.spoolDir} start
  +
  +            ${if cfg.loadDumps == [] then "" else
  +              ''
  +                if [ "$initialize" = "1" ]
  +                then
  +                    # Wait until the ejabberd server is available for use
                       count=0
                       while ! ejabberdctl --config-dir ${cfg.confDir} --logs ${cfg.logsDir} --spool ${cfg.spoolDir} status
                       do
                           if [ $count -eq 30 ]
                           then
                               echo "Tried 30 times, giving up..."
  -	                    exit 1
  +                            exit 1
                           fi
   
                           echo "Ejabberd daemon not yet started. Waiting for 1 second..."
  
positive.code:       loadDumps = mkOption {
          default = [];
          description = "Configuration dump that should be loaded on the first startup";
  	example = [ ./myejabberd.dump ];
        };
      };
      
    };
    
  
    ###### implementation
  
  
negative.code:                         sleep 1
                      done
  
                      ${concatMapStrings (dump:
                        ''
                          echo "Importing dump: ${dump}"
  
                          if [ -f ${dump} ]
                          then
                              ejabberdctl --config-dir ${cfg.confDir} --logs ${cfg.logsDir} --spool ${cfg.spoolDir} load ${dump}
                          elif [ -d ${dump} ]
                          then
                              for i in ${dump}/ejabberd-dump/*
                              do
                                  ejabberdctl --config-dir ${cfg.confDir} --logs ${cfg.logsDir} --spool ${cfg.spoolDir} load $i
                              done
                          fi
                        '') cfg.loadDumps}
                  fi
                ''}
            '';
  
          postStop =
            ''
              ejabberdctl --config-dir ${cfg.confDir} --logs ${cfg.logsDir} --spool ${cfg.spoolDir} stop
            '';
        };
  
    };
  
  }
  