anchor.diff:      "-DICINGA2_GROUP=icinga"
       "-DICINGA2_RUNDIR=/run"
       "-DICINGA2_USER=icinga"
  -    "-DICINGA2_WITH_PGSQL=OFF"
       "-DMYSQL_INCLUDE_DIR=${mariadb.client.dev}/include/mysql"
  -    "-DMYSQL_LIB_DIR=${mariadb.client.out}/lib"
     ];
   
     # XXX Without DESTDIR it tries to write to /icinga2 and /run:
  
positive.code: { stdenv, fetchurl
  , bison, boost, cmake, flex
  , libedit, mariadb, openssl, yajl
  }:
  
  stdenv.mkDerivation rec {
    version = "2.4.10";
    name = "icinga2-${version}";
  
    src = fetchurl {
      url = "https://github.com/Icinga/icinga2/archive/v${version}.tar.gz";
      sha256 = "0pj2y24kgf17106903lnz9gmp5hb3irhafq8sp22qf1wa0q395n2";
    };
  
    buildInputs = [ bison boost cmake flex libedit openssl yajl ];
  
    patches = [
      ./check_mysql_slave.patch
  
negative.code:     rm -rf tmp
      mkdir -p tmp
      make install DESTDIR=$(pwd)/tmp
      mv -v tmp/$out $out
      mv -v tmp/icinga2 $out/icinga2
      rm -rvf $out/run
      for s in $out/icinga2/etc/icinga2/scripts/* ; do
        substituteInPlace $s --replace /usr/bin/printf printf
      done
      rm -vf $out/sbin/icinga2
      ln -svf $out/lib/icinga2/sbin/icinga2 $out/sbin/icinga2
      test -x $out/sbin/icinga2
    '';
  
    buildPhase = ''
      make VERBOSE=1
    '';
  }
  