anchor.diff:      # make sure tests are built in parallel (this can be long otherwise)
       make tests -j $NIX_BUILD_CORES
     '';
  +
  +  postInstall = lib.optionalString withoutBin ''
  +    # remove bin from output if requested.
  +    # having a specific bin output would be cleaner but it does not work currently (circular references)
  +    rm -rf $out/bin
  +  '' + lib.optionalString buildPythonBindings ''
  +    # manually install the python binding if requested.
  +    mkdir -p $python/lib/python${lib.versions.majorMinor python3.version}/site-packages/
  +    cp ./lib/simgrid.cpython*.so $python/lib/python${lib.versions.majorMinor python3.version}/site-packages/
  +   '';
  +
  +  # improve debuggability if requested
  +  hardeningDisable = lib.optionals debug [ "fortify" ];
  +  dontStrip = debug;
   
     meta = {
       description = "Framework for the simulation of distributed applications";
  
positive.code: 
  stdenv.mkDerivation rec {
    pname = "simgrid";
    version = "3.28";
  
    src = fetchFromGitLab {
      domain = "framagit.org";
      owner = pname;
      repo = pname;
      rev = "v${version}";
      sha256 = "0vylwgd4i89bvhbgfay0wq953324dwfmmr8jp9b4vvlc9m0017r9";
    };
  
    patches = [
      (fetchpatch {
        name = "fix-smpi-dirs-absolute.patch";
        url = "https://framagit.org/simgrid/simgrid/-/commit/71f01e667577be1076646eb841e0a57bd5388545.patch";
        sha256 = "0x3y324b6269687zfy43ilc48bwrs4nb7svh2mpg88lrz53rky15";
      })
    ];
  
    propagatedBuildInputs = [ boost ];
    nativeBuildInputs = [ cmake perl python3 valgrind ]
        ++ optionals fortranSupport [ gfortran ]
        ++ optionals buildJavaBindings [ openjdk ]
        ++ optionals buildDocumentation [ fig2dev ghostscript doxygen ]
        ++ optionals modelCheckingSupport [ libunwind libevent elfutils ];
  
    #buildInputs = optional luaSupport lua5;
  
    # Make it so that libsimgrid.so will be found when running programs from
    # the build dir.
    preConfigure = ''
      export LD_LIBRARY_PATH="$PWD/build/lib"
    '';
  
    # Release mode is not supported in SimGrid
    cmakeBuildType = "Debug";
  
    # Disable/Enable functionality
    # Note: those packages are not packaged in Nixpkgs yet so some options
    # are disabled:
    # - papi:   for enable_smpi_papi
    # - ns3:    for enable_ns3
    # - lua53:  for enable_lua
    #
    # For more information see:
    # https://simgrid.org/doc/3.22/Installing_SimGrid.html#simgrid-compilation-options)
    cmakeFlags = [
      "-Denable_documentation=${optionOnOff buildDocumentation}"
      "-Denable_java=${optionOnOff buildJavaBindings}"
      "-Denable_fortran=${optionOnOff fortranSupport}"
      "-Denable_model-checking=${optionOnOff modelCheckingSupport}"
      "-Denable_ns3=off"
  
negative.code: { 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;
  