1{ enableMultiThreading ? true
2, enableG3toG4 ? false
3, enableInventor ? false
4, enableGDML ? false
5, enableQT ? false
6, enableXM ? false
7, enableOpenGLX11 ? true
8, enableRaytracerX11 ? false
9
10# Standard build environment with cmake.
11, stdenv, fetchurl, cmake
12
13# Optional system packages, otherwise internal GEANT4 packages are used.
14, clhep ? null # not packaged currently
15, expat
16, zlib
17
18# For enableGDML.
19, xercesc
20
21# For enableQT.
22, qtbase
23
24# For enableXM.
25, motif
26
27# For enableInventor
28, coin3d
29, soxt
30, libXpm
31
32# For enableQT, enableXM, enableOpenGLX11, enableRaytracerX11.
33, libGLU_combined
34, xlibsWrapper
35, libXmu
36}:
37
38stdenv.mkDerivation rec {
39 version = "10.4.1";
40 name = "geant4-${version}";
41
42 src = fetchurl{
43 url = "http://cern.ch/geant4-data/releases/geant4.10.04.p01.tar.gz";
44 sha256 = "a3eb13e4f1217737b842d3869dc5b1fb978f761113e74bd4eaf6017307d234dd";
45 };
46
47 cmakeFlags = [
48 "-DGEANT4_INSTALL_DATA=OFF"
49 "-DGEANT4_USE_GDML=${if enableGDML then "ON" else "OFF"}"
50 "-DGEANT4_USE_G3TOG4=${if enableG3toG4 then "ON" else "OFF"}"
51 "-DGEANT4_USE_QT=${if enableQT then "ON" else "OFF"}"
52 "-DGEANT4_USE_XM=${if enableXM then "ON" else "OFF"}"
53 "-DGEANT4_USE_OPENGL_X11=${if enableOpenGLX11 then "ON" else "OFF"}"
54 "-DGEANT4_USE_INVENTOR=${if enableInventor then "ON" else "OFF"}"
55 "-DGEANT4_USE_RAYTRACER_X11=${if enableRaytracerX11 then "ON" else "OFF"}"
56 "-DGEANT4_USE_SYSTEM_CLHEP=${if clhep != null then "ON" else "OFF"}"
57 "-DGEANT4_USE_SYSTEM_EXPAT=${if expat != null then "ON" else "OFF"}"
58 "-DGEANT4_USE_SYSTEM_ZLIB=${if zlib != null then "ON" else "OFF"}"
59 "-DGEANT4_BUILD_MULTITHREADED=${if enableMultiThreading then "ON" else "OFF"}"
60 ] ++ stdenv.lib.optionals enableInventor [
61 "-DINVENTOR_INCLUDE_DIR=${coin3d}/include"
62 "-DINVENTOR_LIBRARY_RELEASE=${coin3d}/lib/libCoin.so"
63 ];
64
65 enableParallelBuilding = true;
66 nativeBuildInputs = [ cmake ];
67 buildInputs = [ clhep expat zlib libGLU_combined xlibsWrapper libXmu ]
68 ++ stdenv.lib.optionals enableGDML [ xercesc ]
69 ++ stdenv.lib.optionals enableXM [ motif ]
70 ++ stdenv.lib.optionals enableQT [ qtbase ]
71 ++ stdenv.lib.optionals enableInventor [ libXpm coin3d soxt ];
72
73 postFixup = ''
74 # Don't try to export invalid environment variables.
75 sed -i 's/export G4\([A-Z]*\)DATA/#export G4\1DATA/' "$out"/bin/geant4.sh
76 '';
77
78 setupHook = ./geant4-hook.sh;
79
80 passthru = {
81 data = import ./datasets.nix { inherit stdenv fetchurl; };
82 };
83
84 # Set the myriad of envars required by Geant4 if we use a nix-shell.
85 shellHook = ''
86 source $out/nix-support/setup-hook
87 '';
88
89 meta = with stdenv.lib; {
90 description = "A toolkit for the simulation of the passage of particles through matter";
91 longDescription = ''
92 Geant4 is a toolkit for the simulation of the passage of particles through matter.
93 Its areas of application include high energy, nuclear and accelerator physics, as well as studies in medical and space science.
94 The two main reference papers for Geant4 are published in Nuclear Instruments and Methods in Physics Research A 506 (2003) 250-303, and IEEE Transactions on Nuclear Science 53 No. 1 (2006) 270-278.
95 '';
96 homepage = http://www.geant4.org;
97 license = licenses.g4sl;
98 maintainers = with maintainers; [ tmplt ];
99 platforms = platforms.linux;
100 };
101}