anchor.diff:      "-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1"
       "-DWITHOUT_FEDERATED_STORAGE_ENGINE=1"
       "-DWITH_WSREP=ON"
  +    "-DWITH_INNODB_DISALLOW_WRITES=ON"
     ] ++ stdenv.lib.optionals stdenv.isDarwin [
       "-DWITHOUT_OQGRAPH_STORAGE_ENGINE=1"
       "-DWITHOUT_TOKUDB=1"
  
positive.code: , openssl, pcre, boost, judy, bison, libxml2
  , libaio, libevent, groff, jemalloc, cracklib, systemd, numactl, perl
  , fixDarwinDylibNames, cctools, CoreServices
  }:
  
  with stdenv.lib;
  
negative.code:   };
  };
  
  galera = stdenv.mkDerivation rec {
    name = "mariadb-galera-${version}";
    version = "25.3.23";
  
    src = fetchurl {
      url = "https://mirrors.nxthost.com/mariadb/mariadb-10.2.14/galera-${version}/src/galera-${version}.tar.gz";
      sha256 = "11pfc85z29jk0h6g6bmi3hdv4in4yb00xsr2r0qm1b0y7m2wq3ra";
    };
  
    buildInputs = [ asio boost check openssl qt4 scons ];
  
    patchPhase = ''
      substituteInPlace SConstruct \
        --replace "boost_library_path = '''" "boost_library_path = '${boost}/lib'"
    '';
  
    preConfigure = ''
      export CPPFLAGS="-I${asio}/include  -I${boost.dev}/include -I${check}/include -I${openssl.dev}/include"
      export LIBPATH="${galeraLibs}/lib"
    '';
  
    buildPhase = ''
       scons -j$NIX_BUILD_CORES ssl=1 system_asio=1 strict_build_flags=0
    '';
  
    installPhase = ''
      # copied with modifications from scripts/packages/freebsd.sh
      GALERA_LICENSE_DIR="$share/licenses/${name}"
      install -d $out/{bin,lib/galera,share/doc/galera,$GALERA_LICENSE_DIR}
      install -m 555 "garb/garbd"                       "$out/bin/garbd"
      install -m 444 "libgalera_smm.so"                 "$out/lib/galera/libgalera_smm.so"
      install -m 444 "scripts/packages/README"          "$out/share/doc/galera/"
      install -m 444 "scripts/packages/README-MySQL"    "$out/share/doc/galera/"
      install -m 444 "scripts/packages/freebsd/LICENSE" "$out/$GALERA_LICENSE_DIR"
      install -m 444 "LICENSE"                          "$out/$GALERA_LICENSE_DIR/GPLv2"
      install -m 444 "asio/LICENSE_1_0.txt"             "$out/$GALERA_LICENSE_DIR/LICENSE.asio"
      install -m 444 "www.evanjones.ca/LICENSE"         "$out/$GALERA_LICENSE_DIR/LICENSE.crc32c"
      install -m 444 "chromium/LICENSE"                 "$out/$GALERA_LICENSE_DIR/LICENSE.chromium"
    '';
  
    meta = {
      description = "Galera 3 wsrep provider library";
      homepage = http://galeracluster.com/;
      license = licenses.lgpl2;
      maintainers = with maintainers; [ izorkin ];
      platforms = platforms.all;
    };
  };
  in mariadb
  