1 { enableMultiThreading ? true
2 , enableInventor ? false
3 , enableQT ? false # deprecated name
7 , enableOpenGLX11 ? !stdenv.isDarwin
9 , enableRaytracerX11 ? false
11 # Standard build environment with cmake.
12 , lib, stdenv, fetchurl, cmake
31 # For enableQt, enableXM, enableOpenGLX11, enableRaytracerX11.
45 boost_python = boost.override { enablePython = true; python = python3; };
48 lib.warnIf (enableQT != false) "geant4: enableQT is deprecated, please use enableQt"
50 stdenv.mkDerivation rec {
55 url = "https://cern.ch/geant4-data/releases/geant4-v${version}.tar.gz";
56 hash = "sha256-0k9lc1uKCgOcAPlDSZHpnvEZuGxRDQ8qshFV24KjSR0=";
59 # Fix broken paths in a .pc
61 substituteInPlace source/externals/ptl/cmake/Modules/PTLPackageConfigHelpers.cmake \
62 --replace '${"$"}{prefix}/${"$"}{PTL_INSTALL_' '${"$"}{PTL_INSTALL_'
66 "-DGEANT4_INSTALL_DATA=OFF"
67 "-DGEANT4_USE_GDML=ON"
68 "-DGEANT4_USE_G3TOG4=ON"
69 "-DGEANT4_USE_QT=${if enableQt then "ON" else "OFF"}"
70 "-DGEANT4_USE_XM=${if enableXM then "ON" else "OFF"}"
71 "-DGEANT4_USE_OPENGL_X11=${if enableOpenGLX11 then "ON" else "OFF"}"
72 "-DGEANT4_USE_INVENTOR=${if enableInventor then "ON" else "OFF"}"
73 "-DGEANT4_USE_PYTHON=${if enablePython then "ON" else "OFF"}"
74 "-DGEANT4_USE_RAYTRACER_X11=${if enableRaytracerX11 then "ON" else "OFF"}"
75 "-DGEANT4_USE_SYSTEM_CLHEP=ON"
76 "-DGEANT4_USE_SYSTEM_EXPAT=ON"
77 "-DGEANT4_USE_SYSTEM_ZLIB=ON"
78 "-DGEANT4_BUILD_MULTITHREADED=${if enableMultiThreading then "ON" else "OFF"}"
79 ] ++ lib.optionals (enableOpenGLX11 && stdenv.hostPlatform.isDarwin) [
80 "-DXQuartzGL_INCLUDE_DIR=${libGLX.dev}/include"
81 "-DXQuartzGL_gl_LIBRARY=${libGLX}/lib/libGL.dylib"
82 ] ++ lib.optionals (enableMultiThreading && enablePython) [
83 "-DGEANT4_BUILD_TLS_MODEL=global-dynamic"
84 ] ++ lib.optionals enableInventor [
85 "-DINVENTOR_INCLUDE_DIR=${coin3d}/include"
86 "-DINVENTOR_LIBRARY_RELEASE=${coin3d}/lib/libCoin.so"
93 propagatedNativeBuildInputs = lib.optionals enableQt [
96 dontWrapQtApps = true; # no binaries
99 lib.optionals enableOpenGLX11 [ libGLU libXext libXmu ]
100 ++ lib.optionals enableInventor [ libXpm coin3d soxt motif ]
101 ++ lib.optionals enablePython [ boost_python python3 ];
103 propagatedBuildInputs = [ clhep expat xercesc zlib ]
104 ++ lib.optionals enableOpenGLX11 [ libGL ]
105 ++ lib.optionals enableXM [ motif ]
106 ++ lib.optionals enableQt [ qtbase ];
109 # Don't try to export invalid environment variables.
110 sed -i 's/export G4\([A-Z]*\)DATA/#export G4\1DATA/' "$out"/bin/geant4.sh
111 '' + lib.optionalString enableQt ''
115 setupHook = ./geant4-hook.sh;
118 data = callPackage ./datasets.nix {};
120 tests = callPackage ./tests.nix {};
125 # Set the myriad of envars required by Geant4 if we use a nix-shell.
127 source $out/nix-support/setup-hook
131 broken = (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64);
132 description = "Toolkit for the simulation of the passage of particles through matter";
134 Geant4 is a toolkit for the simulation of the passage of particles through matter.
135 Its areas of application include high energy, nuclear and accelerator physics, as well as studies in medical and space science.
136 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.
138 homepage = "http://www.geant4.org";
139 license = licenses.g4sl;
140 maintainers = with maintainers; [ omnipotententity veprbl ];
141 platforms = platforms.unix;