Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 callPackage, 6 boost, 7 clhep, 8 cmake, 9 coin3d, 10 expat, 11 libGL, 12 libGLU, 13 libGLX, 14 libX11, 15 libXext, 16 libXmu, 17 libXpm, 18 motif, 19 python3, 20 qt5, 21 soxt, 22 xercesc, 23 zlib, 24 enableMultiThreading ? true, 25 enableInventor ? false, 26 enableQt ? false, 27 enableXM ? false, 28 enableOpenGLX11 ? !stdenv.hostPlatform.isDarwin, 29 enablePython ? false, 30 enableRaytracerX11 ? false, 31}: 32 33let 34 boost_python = boost.override { 35 enablePython = true; 36 python = python3; 37 }; 38in 39 40stdenv.mkDerivation rec { 41 version = "11.3.2"; 42 pname = "geant4"; 43 44 src = fetchurl { 45 url = "https://cern.ch/geant4-data/releases/geant4-v${version}.tar.gz"; 46 hash = "sha256-iSrt10JSYqUKw9PHEX2BwMDaS0CMaIDbr1R4uTAeSIw="; 47 }; 48 49 # Fix broken paths in a .pc 50 postPatch = '' 51 substituteInPlace source/externals/ptl/cmake/Modules/PTLPackageConfigHelpers.cmake \ 52 --replace '${"$"}{prefix}/${"$"}{PTL_INSTALL_' '${"$"}{PTL_INSTALL_' 53 ''; 54 55 cmakeFlags = [ 56 "-DGEANT4_INSTALL_DATA=OFF" 57 "-DGEANT4_USE_GDML=ON" 58 "-DGEANT4_USE_G3TOG4=ON" 59 "-DGEANT4_USE_QT=${if enableQt then "ON" else "OFF"}" 60 "-DGEANT4_USE_XM=${if enableXM then "ON" else "OFF"}" 61 "-DGEANT4_USE_OPENGL_X11=${if enableOpenGLX11 then "ON" else "OFF"}" 62 "-DGEANT4_USE_INVENTOR=${if enableInventor then "ON" else "OFF"}" 63 "-DGEANT4_USE_PYTHON=${if enablePython then "ON" else "OFF"}" 64 "-DGEANT4_USE_RAYTRACER_X11=${if enableRaytracerX11 then "ON" else "OFF"}" 65 "-DGEANT4_USE_SYSTEM_CLHEP=ON" 66 "-DGEANT4_USE_SYSTEM_EXPAT=ON" 67 "-DGEANT4_USE_SYSTEM_ZLIB=ON" 68 "-DGEANT4_BUILD_MULTITHREADED=${if enableMultiThreading then "ON" else "OFF"}" 69 ] 70 ++ lib.optionals (enableOpenGLX11 && stdenv.hostPlatform.isDarwin) [ 71 "-DXQuartzGL_INCLUDE_DIR=${libGLX.dev}/include" 72 "-DXQuartzGL_gl_LIBRARY=${libGLX}/lib/libGL.dylib" 73 ] 74 ++ lib.optionals (enableMultiThreading && enablePython) [ 75 "-DGEANT4_BUILD_TLS_MODEL=global-dynamic" 76 ] 77 ++ lib.optionals enableInventor [ 78 "-DINVENTOR_INCLUDE_DIR=${coin3d}/include" 79 "-DINVENTOR_LIBRARY_RELEASE=${coin3d}/lib/libCoin.so" 80 ]; 81 82 nativeBuildInputs = [ cmake ]; 83 84 propagatedNativeBuildInputs = lib.optionals enableQt [ qt5.wrapQtAppsHook ]; 85 dontWrapQtApps = true; # no binaries 86 87 buildInputs = 88 lib.optionals enableOpenGLX11 [ 89 libGLU 90 libXext 91 libXmu 92 ] 93 ++ lib.optionals enableInventor [ 94 libXpm 95 coin3d 96 soxt 97 motif 98 ] 99 ++ lib.optionals enablePython [ 100 boost_python 101 python3 102 ]; 103 104 propagatedBuildInputs = [ 105 clhep 106 expat 107 xercesc 108 zlib 109 ] 110 ++ lib.optionals enableOpenGLX11 [ 111 libGL 112 libX11 113 ] 114 ++ lib.optionals enableXM [ motif ] 115 ++ lib.optionals enableQt [ qt5.qtbase ]; 116 117 postFixup = '' 118 substituteInPlace "$out"/bin/geant4.sh \ 119 --replace-fail "export GEANT4_DATA_DIR" "# export GEANT4_DATA_DIR" 120 '' 121 + lib.optionalString enableQt '' 122 wrapQtAppsHook 123 ''; 124 125 setupHook = ./geant4-hook.sh; 126 127 passthru = { 128 data = callPackage ./datasets.nix { }; 129 130 tests = callPackage ./tests.nix { }; 131 132 inherit enableQt; 133 }; 134 135 # Set the myriad of envars required by Geant4 if we use a nix-shell. 136 shellHook = '' 137 source $out/nix-support/setup-hook 138 ''; 139 140 meta = with lib; { 141 description = "Toolkit for the simulation of the passage of particles through matter"; 142 longDescription = '' 143 Geant4 is a toolkit for the simulation of the passage of particles through matter. 144 Its areas of application include high energy, nuclear and accelerator physics, as well as studies in medical and space science. 145 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. 146 ''; 147 homepage = "https://www.geant4.org"; 148 license = licenses.g4sl; 149 maintainers = with maintainers; [ 150 omnipotententity 151 veprbl 152 ]; 153 platforms = platforms.unix; 154 }; 155}