2020-04-24 23:36:52 +00:00
|
|
|
{ enableMultiThreading ? true
|
|
|
|
, enableG3toG4 ? false
|
|
|
|
, enableInventor ? false
|
|
|
|
, enableGDML ? false
|
|
|
|
, enableQT ? false
|
|
|
|
, enableXM ? false
|
|
|
|
, enableOpenGLX11 ? true
|
2020-06-18 07:06:33 +00:00
|
|
|
, enablePython ? false
|
2020-04-24 23:36:52 +00:00
|
|
|
, enableRaytracerX11 ? false
|
|
|
|
|
|
|
|
# Standard build environment with cmake.
|
2021-02-05 17:12:51 +00:00
|
|
|
, lib, stdenv, fetchurl, fetchpatch, cmake
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Optional system packages, otherwise internal GEANT4 packages are used.
|
|
|
|
, clhep ? null # not packaged currently
|
|
|
|
, expat
|
|
|
|
, zlib
|
|
|
|
|
|
|
|
# For enableGDML.
|
|
|
|
, xercesc
|
|
|
|
|
|
|
|
# For enableQT.
|
|
|
|
, qtbase
|
2021-02-22 21:28:39 +00:00
|
|
|
, wrapQtAppsHook
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# For enableXM.
|
|
|
|
, motif
|
|
|
|
|
|
|
|
# For enableInventor
|
|
|
|
, coin3d
|
|
|
|
, soxt
|
|
|
|
, libXpm
|
|
|
|
|
|
|
|
# For enableQT, enableXM, enableOpenGLX11, enableRaytracerX11.
|
|
|
|
, libGLU, libGL
|
|
|
|
, xlibsWrapper
|
|
|
|
, libXmu
|
2020-06-18 07:06:33 +00:00
|
|
|
|
|
|
|
# For enablePython
|
|
|
|
, boost
|
|
|
|
, python3
|
2020-11-12 09:05:59 +00:00
|
|
|
|
|
|
|
# For tests
|
|
|
|
, callPackage
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
let
|
|
|
|
boost_python = boost.override { enablePython = true; python = python3; };
|
|
|
|
in
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2021-12-19 01:06:50 +00:00
|
|
|
version = "11.0.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "geant4";
|
|
|
|
|
|
|
|
src = fetchurl{
|
2021-12-19 01:06:50 +00:00
|
|
|
url = "https://cern.ch/geant4-data/releases/geant4-v${version}.tar.gz";
|
|
|
|
sha256 = "sha256-PMin350/8ceiGmLS6zoQvhX2uxWNOTI78yEzScnvdbk=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DGEANT4_INSTALL_DATA=OFF"
|
|
|
|
"-DGEANT4_USE_GDML=${if enableGDML then "ON" else "OFF"}"
|
|
|
|
"-DGEANT4_USE_G3TOG4=${if enableG3toG4 then "ON" else "OFF"}"
|
|
|
|
"-DGEANT4_USE_QT=${if enableQT then "ON" else "OFF"}"
|
|
|
|
"-DGEANT4_USE_XM=${if enableXM then "ON" else "OFF"}"
|
|
|
|
"-DGEANT4_USE_OPENGL_X11=${if enableOpenGLX11 then "ON" else "OFF"}"
|
|
|
|
"-DGEANT4_USE_INVENTOR=${if enableInventor then "ON" else "OFF"}"
|
2020-06-18 07:06:33 +00:00
|
|
|
"-DGEANT4_USE_PYTHON=${if enablePython then "ON" else "OFF"}"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DGEANT4_USE_RAYTRACER_X11=${if enableRaytracerX11 then "ON" else "OFF"}"
|
|
|
|
"-DGEANT4_USE_SYSTEM_CLHEP=${if clhep != null then "ON" else "OFF"}"
|
|
|
|
"-DGEANT4_USE_SYSTEM_EXPAT=${if expat != null then "ON" else "OFF"}"
|
|
|
|
"-DGEANT4_USE_SYSTEM_ZLIB=${if zlib != null then "ON" else "OFF"}"
|
|
|
|
"-DGEANT4_BUILD_MULTITHREADED=${if enableMultiThreading then "ON" else "OFF"}"
|
2021-02-05 17:12:51 +00:00
|
|
|
] ++ lib.optionals (enableMultiThreading && enablePython) [
|
2020-06-18 07:06:33 +00:00
|
|
|
"-DGEANT4_BUILD_TLS_MODEL=global-dynamic"
|
2021-02-05 17:12:51 +00:00
|
|
|
] ++ lib.optionals enableInventor [
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DINVENTOR_INCLUDE_DIR=${coin3d}/include"
|
|
|
|
"-DINVENTOR_LIBRARY_RELEASE=${coin3d}/lib/libCoin.so"
|
|
|
|
];
|
|
|
|
|
2021-02-22 21:28:39 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
] ++ lib.optionals enableQT [
|
|
|
|
wrapQtAppsHook
|
|
|
|
];
|
|
|
|
|
|
|
|
dontWrapQtApps = !enableQT;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildInputs = [ libGLU xlibsWrapper libXmu ]
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.optionals enableInventor [ libXpm coin3d soxt motif ]
|
|
|
|
++ lib.optionals enablePython [ boost_python python3 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
propagatedBuildInputs = [ clhep expat zlib libGL ]
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.optionals enableGDML [ xercesc ]
|
|
|
|
++ lib.optionals enableXM [ motif ]
|
|
|
|
++ lib.optionals enableQT [ qtbase ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
# Don't try to export invalid environment variables.
|
|
|
|
sed -i 's/export G4\([A-Z]*\)DATA/#export G4\1DATA/' "$out"/bin/geant4.sh
|
2021-02-22 21:28:39 +00:00
|
|
|
'' + lib.optionalString enableQT ''
|
|
|
|
wrapQtAppsHook
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
setupHook = ./geant4-hook.sh;
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
data = import ./datasets.nix {
|
2021-02-05 17:12:51 +00:00
|
|
|
inherit lib stdenv fetchurl;
|
2020-04-24 23:36:52 +00:00
|
|
|
geant_version = version;
|
|
|
|
};
|
2020-11-12 09:05:59 +00:00
|
|
|
|
|
|
|
tests = callPackage ./tests.nix {};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# Set the myriad of envars required by Geant4 if we use a nix-shell.
|
|
|
|
shellHook = ''
|
|
|
|
source $out/nix-support/setup-hook
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2022-06-16 17:23:12 +00:00
|
|
|
broken = (stdenv.isLinux && stdenv.isAarch64);
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A toolkit for the simulation of the passage of particles through matter";
|
|
|
|
longDescription = ''
|
|
|
|
Geant4 is a toolkit for the simulation of the passage of particles through matter.
|
|
|
|
Its areas of application include high energy, nuclear and accelerator physics, as well as studies in medical and space science.
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
homepage = "http://www.geant4.org";
|
|
|
|
license = licenses.g4sl;
|
2021-12-19 01:06:50 +00:00
|
|
|
maintainers = with maintainers; [ omnipotententity ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|