Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / science / misc / simgrid / default.nix
blob2df4ce414dcfee03cf45fb7873d2ce3f4ad3af93
1 { stdenv, lib, fetchFromGitLab, cmake, perl, python3, boost
2 , fortranSupport ? false, gfortran
3 , buildDocumentation ? false, fig2dev, ghostscript, doxygen
4 , buildJavaBindings ? false, openjdk
5 , buildPythonBindings ? true, python3Packages
6 , modelCheckingSupport ? false, libunwind, libevent, elfutils # Inside elfutils: libelf and libdw
7 , bmfSupport ? true, eigen
8 , minimalBindings ? false
9 , debug ? false
10 , optimize ? (!debug)
11 , moreTests ? false
12 , withoutBin ? false
15 with lib;
17 let
18   optionOnOff = option: if option then "on" else "off";
21 stdenv.mkDerivation rec {
22   pname = "simgrid";
23   version = "3.34";
25   src = fetchFromGitLab {
26     domain = "framagit.org";
27     owner = pname;
28     repo = pname;
29     rev = "v${version}";
30     sha256 = "sha256-EVTpW9jD1h8T2KRlDIqptKS6Wv1dVDfyJbXxrpsgmoo=";
31   };
33   propagatedBuildInputs = [ boost ];
34   nativeBuildInputs = [ cmake perl python3 ]
35     ++ optionals fortranSupport [ gfortran ]
36     ++ optionals buildJavaBindings [ openjdk ]
37     ++ optionals buildPythonBindings [ python3Packages.pybind11 ]
38     ++ optionals buildDocumentation [ fig2dev ghostscript doxygen ]
39     ++ optionals bmfSupport [ eigen ]
40     ++ optionals modelCheckingSupport [ libunwind libevent elfutils ];
42   outputs = [ "out" ]
43     ++ optionals buildPythonBindings [ "python" ];
45   # "Release" does not work. non-debug mode is Debug compiled with optimization
46   cmakeBuildType = "Debug";
47   cmakeFlags = [
48     "-Denable_documentation=${optionOnOff buildDocumentation}"
49     "-Denable_java=${optionOnOff buildJavaBindings}"
50     "-Denable_python=${optionOnOff buildPythonBindings}"
51     "-DSIMGRID_PYTHON_LIBDIR=./" # prevents CMake to install in ${python3} dir
52     "-Denable_msg=${optionOnOff buildJavaBindings}"
53     "-Denable_fortran=${optionOnOff fortranSupport}"
54     "-Denable_model-checking=${optionOnOff modelCheckingSupport}"
55     "-Denable_ns3=off"
56     "-Denable_lua=off"
57     "-Denable_lib_in_jar=off"
58     "-Denable_maintainer_mode=off"
59     "-Denable_mallocators=on"
60     "-Denable_debug=on"
61     "-Denable_smpi=on"
62     "-Dminimal-bindings=${optionOnOff minimalBindings}"
63     "-Denable_smpi_ISP_testsuite=${optionOnOff moreTests}"
64     "-Denable_smpi_MPICH3_testsuite=${optionOnOff moreTests}"
65     "-Denable_compile_warnings=off"
66     "-Denable_compile_optimizations=${optionOnOff optimize}"
67     "-Denable_lto=${optionOnOff optimize}"
69     # RPATH of binary /nix/store/.../bin/... contains a forbidden reference to /build/
70     "-DCMAKE_SKIP_BUILD_RPATH=ON"
71   ];
72   makeFlags = optional debug "VERBOSE=1";
74   # needed to run tests and to ensure correct shabangs in output scripts
75   preBuild = ''
76     patchShebangs ..
77   '';
79   # needed by tests (so libsimgrid.so is found)
80   preConfigure = ''
81     export LD_LIBRARY_PATH="$PWD/build/lib"
82   '';
84   doCheck = true;
85   preCheck = ''
86     # prevent the execution of tests known to fail
87     cat <<EOW >CTestCustom.cmake
88     SET(CTEST_CUSTOM_TESTS_IGNORE smpi-replay-multiple)
89     EOW
91     # make sure tests are built in parallel (this can be long otherwise)
92     make tests -j $NIX_BUILD_CORES
93   '';
95   postInstall = lib.optionalString withoutBin ''
96     # remove bin from output if requested.
97     # having a specific bin output would be cleaner but it does not work currently (circular references)
98     rm -rf $out/bin
99   '' + lib.optionalString buildPythonBindings ''
100     # manually install the python binding if requested.
101     mkdir -p $python/lib/python${lib.versions.majorMinor python3.version}/site-packages/
102     cp ./lib/simgrid.cpython*.so $python/lib/python${lib.versions.majorMinor python3.version}/site-packages/
103    '';
105   # improve debuggability if requested
106   hardeningDisable = lib.optionals debug [ "fortify" ];
107   dontStrip = debug;
109   meta = {
110     description = "Framework for the simulation of distributed applications";
111     longDescription = ''
112       SimGrid is a toolkit that provides core functionalities for the
113       simulation of distributed applications in heterogeneous distributed
114       environments.  The specific goal of the project is to facilitate
115       research in the area of distributed and parallel application
116       scheduling on distributed computing platforms ranging from simple
117       network of workstations to Computational Grids.
118     '';
119     homepage = "https://simgrid.org/";
120     license = licenses.lgpl2Plus;
121     maintainers = with maintainers; [ mickours mpoquet ];
122     platforms = platforms.all;
123     broken = stdenv.isDarwin;
124   };