1 { enableMultiThreading ? true
2 , enableInventor ? false
3 , enableQT ? false # deprecated name
6 , enableOpenGLX11 ? true
8 , enableRaytracerX11 ? false
10 # Standard build environment with cmake.
11 , lib, stdenv, fetchurl, fetchpatch, cmake
30 # For enableQt, enableXM, enableOpenGLX11, enableRaytracerX11.
44 boost_python = boost.override { enablePython = true; python = python3; };
47 lib.warnIf (enableQT != false) "geant4: enableQT is deprecated, please use enableQt"
49 stdenv.mkDerivation rec {
54 url = "https://cern.ch/geant4-data/releases/geant4-v${version}.tar.gz";
55 hash = "sha256-cvi2h1EtbmMNxsZMXEG6cRIgRoVAEymZ0A5PzhkIrkg=";
59 "-DGEANT4_INSTALL_DATA=OFF"
60 "-DGEANT4_USE_GDML=ON"
61 "-DGEANT4_USE_G3TOG4=ON"
62 "-DGEANT4_USE_QT=${if enableQt then "ON" else "OFF"}"
63 "-DGEANT4_USE_XM=${if enableXM then "ON" else "OFF"}"
64 "-DGEANT4_USE_OPENGL_X11=${if enableOpenGLX11 then "ON" else "OFF"}"
65 "-DGEANT4_USE_INVENTOR=${if enableInventor then "ON" else "OFF"}"
66 "-DGEANT4_USE_PYTHON=${if enablePython then "ON" else "OFF"}"
67 "-DGEANT4_USE_RAYTRACER_X11=${if enableRaytracerX11 then "ON" else "OFF"}"
68 "-DGEANT4_USE_SYSTEM_CLHEP=ON"
69 "-DGEANT4_USE_SYSTEM_EXPAT=ON"
70 "-DGEANT4_USE_SYSTEM_ZLIB=ON"
71 "-DGEANT4_BUILD_MULTITHREADED=${if enableMultiThreading then "ON" else "OFF"}"
72 ] ++ lib.optionals stdenv.isDarwin [
73 "-DXQuartzGL_INCLUDE_DIR=${libGL.dev}/include"
74 "-DXQuartzGL_gl_LIBRARY=${libGL}/lib/libGL.dylib"
75 ] ++ lib.optionals (enableMultiThreading && enablePython) [
76 "-DGEANT4_BUILD_TLS_MODEL=global-dynamic"
77 ] ++ lib.optionals enableInventor [
78 "-DINVENTOR_INCLUDE_DIR=${coin3d}/include"
79 "-DINVENTOR_LIBRARY_RELEASE=${coin3d}/lib/libCoin.so"
86 propagatedNativeBuildInputs = lib.optionals enableQt [
89 dontWrapQtApps = true; # no binaries
91 buildInputs = [ libGLU xlibsWrapper libXmu ]
92 ++ lib.optionals enableInventor [ libXpm coin3d soxt motif ]
93 ++ lib.optionals enablePython [ boost_python python3 ];
95 propagatedBuildInputs = [ clhep expat xercesc zlib libGL ]
96 ++ lib.optionals enableXM [ motif ]
97 ++ lib.optionals enableQt [ qtbase ];
100 # Don't try to export invalid environment variables.
101 sed -i 's/export G4\([A-Z]*\)DATA/#export G4\1DATA/' "$out"/bin/geant4.sh
102 '' + lib.optionalString enableQt ''
106 setupHook = ./geant4-hook.sh;
109 data = callPackage ./datasets.nix {};
111 tests = callPackage ./tests.nix {};
116 # Set the myriad of envars required by Geant4 if we use a nix-shell.
118 source $out/nix-support/setup-hook
122 broken = (stdenv.isLinux && stdenv.isAarch64);
123 description = "A toolkit for the simulation of the passage of particles through matter";
125 Geant4 is a toolkit for the simulation of the passage of particles through matter.
126 Its areas of application include high energy, nuclear and accelerator physics, as well as studies in medical and space science.
127 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.
129 homepage = "http://www.geant4.org";
130 license = licenses.g4sl;
131 maintainers = with maintainers; [ omnipotententity veprbl ];
132 platforms = platforms.unix;