anchor.diff: -{ lib, stdenv, fetchFromGitLab, fetchpatch, cmake, perl, python3, boost, valgrind
  -# Optional requirements
  -# Lua 5.3 needed and not available now
  -#, luaSupport ? false, lua5
  +{ stdenv, lib, fetchFromGitLab, cmake, perl, python3, boost
   , fortranSupport ? false, gfortran
   , buildDocumentation ? false, fig2dev, ghostscript, doxygen
   , buildJavaBindings ? false, openjdk
  +, buildPythonBindings ? true, python3Packages
   , modelCheckingSupport ? false, libunwind, libevent, elfutils # Inside elfutils: libelf and libdw
  +, minimalBindings ? false
   , debug ? false
  +, optimize ? (!debug)
   , moreTests ? false
  +, withoutBin ? false
   }:
   
   with lib;
  
positive.code:     "-Denable_mallocators=on"
      "-Denable_debug=on"
      "-Denable_smpi=on"
      "-Denable_smpi_ISP_testsuite=${optionOnOff moreTests}"
      "-Denable_smpi_MPICH3_testsuite=${optionOnOff moreTests}"
      "-Denable_compile_warnings=${optionOnOff debug}"
      "-Denable_compile_optimizations=${optionOnOff (!debug)}"
      "-Denable_lto=${optionOnOff (!debug)}"
      # "-Denable_lua=${optionOnOff luaSupport}"
      # "-Denable_smpi_papi=${optionOnOff moreTests}"
    ];
  
    makeFlags = optional debug "VERBOSE=1";
  
    # Some Perl scripts are called to generate test during build which
    # is before the fixupPhase, so do this manualy here:
    preBuild = ''
      patchShebangs ..
    '';
  
    doCheck = true;
  
    # Prevent the execution of tests known to fail.
    preCheck = ''
      cat <<EOW >CTestCustom.cmake
      SET(CTEST_CUSTOM_TESTS_IGNORE smpi-replay-multiple)
      EOW
  
negative.code: 
  stdenv.mkDerivation rec {
    pname = "simgrid";
    version = "3.30";
  
    src = fetchFromGitLab {
      domain = "framagit.org";
      owner = pname;
      repo = pname;
      rev = "v${version}";
      sha256 = "1dg8ywqif20g0fs8dnd6364n080nvwx7f444zcfwqwz6iax61qv1";
    };
  
    propagatedBuildInputs = [ boost ];
    nativeBuildInputs = [ cmake perl python3 ]
      ++ optionals fortranSupport [ gfortran ]
      ++ optionals buildJavaBindings [ openjdk ]
      ++ optionals buildPythonBindings [ python3Packages.pybind11 ]
      ++ optionals buildDocumentation [ fig2dev ghostscript doxygen ]
      ++ optionals modelCheckingSupport [ libunwind libevent elfutils ];
  
    outputs = [ "out" ]
      ++ optionals buildPythonBindings [ "python" ];
  
    # "Release" does not work. non-debug mode is Debug compiled with optimization
    cmakeBuildType = "Debug";
    cmakeFlags = [
      "-Denable_documentation=${optionOnOff buildDocumentation}"
      "-Denable_java=${optionOnOff buildJavaBindings}"
      "-Denable_python=${optionOnOff buildPythonBindings}"
      "-DSIMGRID_PYTHON_LIBDIR=./" # prevents CMake to install in ${python3} dir
      "-Denable_msg=${optionOnOff buildJavaBindings}"
      "-Denable_fortran=${optionOnOff fortranSupport}"
      "-Denable_model-checking=${optionOnOff modelCheckingSupport}"
      "-Denable_ns3=off"
  