at 23.11-beta 4.0 kB view raw
1{ enableMultiThreading ? true 2, enableInventor ? false 3, enableQT ? false # deprecated name 4, enableQt ? enableQT 5, enableXM ? false 6, enableOpenGLX11 ? true 7, enablePython ? false 8, enableRaytracerX11 ? false 9 10# Standard build environment with cmake. 11, lib, stdenv, fetchurl, fetchpatch, cmake 12 13, clhep 14, expat 15, xercesc 16, zlib 17 18# For enableQt. 19, qtbase 20, wrapQtAppsHook 21 22# For enableXM. 23, motif 24 25# For enableInventor 26, coin3d 27, soxt 28, libXpm 29 30# For enableQt, enableXM, enableOpenGLX11, enableRaytracerX11. 31, libGLU, libGL 32, libXext 33, libXmu 34 35# For enablePython 36, boost 37, python3 38 39# For tests 40, callPackage 41}: 42 43let 44 boost_python = boost.override { enablePython = true; python = python3; }; 45in 46 47lib.warnIf (enableQT != false) "geant4: enableQT is deprecated, please use enableQt" 48 49stdenv.mkDerivation rec { 50 version = "11.0.4"; 51 pname = "geant4"; 52 53 src = fetchurl { 54 url = "https://cern.ch/geant4-data/releases/geant4-v${version}.tar.gz"; 55 hash = "sha256-4wofoo0vLPd8/9CFY8EonpL8R9mcg5Wa9H/ve9UDSyc="; 56 }; 57 58 cmakeFlags = [ 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" 80 ]; 81 82 nativeBuildInputs = [ 83 cmake 84 ]; 85 86 propagatedNativeBuildInputs = lib.optionals enableQt [ 87 wrapQtAppsHook 88 ]; 89 dontWrapQtApps = true; # no binaries 90 91 buildInputs = [ libGLU libXext libXmu ] 92 ++ lib.optionals enableInventor [ libXpm coin3d soxt motif ] 93 ++ lib.optionals enablePython [ boost_python python3 ]; 94 95 propagatedBuildInputs = [ clhep expat xercesc zlib libGL ] 96 ++ lib.optionals enableXM [ motif ] 97 ++ lib.optionals enableQt [ qtbase ]; 98 99 postFixup = '' 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 '' 103 wrapQtAppsHook 104 ''; 105 106 setupHook = ./geant4-hook.sh; 107 108 passthru = { 109 data = callPackage ./datasets.nix {}; 110 111 tests = callPackage ./tests.nix {}; 112 113 inherit enableQt; 114 }; 115 116 # Set the myriad of envars required by Geant4 if we use a nix-shell. 117 shellHook = '' 118 source $out/nix-support/setup-hook 119 ''; 120 121 meta = with lib; { 122 broken = (stdenv.isLinux && stdenv.isAarch64); 123 description = "A toolkit for the simulation of the passage of particles through matter"; 124 longDescription = '' 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. 128 ''; 129 homepage = "http://www.geant4.org"; 130 license = licenses.g4sl; 131 maintainers = with maintainers; [ omnipotententity veprbl ]; 132 platforms = platforms.unix; 133 }; 134}