about summary refs log tree commit diff
path: root/pkgs/development/libraries/physics
diff options
context:
space:
mode:
authorChristopher Poole <mail@christopherpoole.net>2014-09-04 17:21:42 +1000
committerChristopher Poole <mail@christopherpoole.net>2014-09-04 17:21:42 +1000
commit2c3fbe3a8e5c003410d32817b0465a854bb63321 (patch)
tree5e8d161a22b4a31191ffb2b512370d0574c2332e /pkgs/development/libraries/physics
parent0c398f60405090743fbdcf14faf1193c642b6328 (diff)
downloadnixlib-2c3fbe3a8e5c003410d32817b0465a854bb63321.tar
nixlib-2c3fbe3a8e5c003410d32817b0465a854bb63321.tar.gz
nixlib-2c3fbe3a8e5c003410d32817b0465a854bb63321.tar.bz2
nixlib-2c3fbe3a8e5c003410d32817b0465a854bb63321.tar.lz
nixlib-2c3fbe3a8e5c003410d32817b0465a854bb63321.tar.xz
nixlib-2c3fbe3a8e5c003410d32817b0465a854bb63321.tar.zst
nixlib-2c3fbe3a8e5c003410d32817b0465a854bb63321.zip
Add the Geant4 Monte Carlo radiation transport toolkit and its Python bindings.
Diffstat (limited to 'pkgs/development/libraries/physics')
-rw-r--r--pkgs/development/libraries/physics/geant4/default.nix181
-rw-r--r--pkgs/development/libraries/physics/geant4/fetch.nix78
-rw-r--r--pkgs/development/libraries/physics/geant4/g4py/configure.patch12
-rw-r--r--pkgs/development/libraries/physics/geant4/g4py/default.nix105
-rw-r--r--pkgs/development/libraries/physics/geant4/g4py/setup-hook.sh1
-rw-r--r--pkgs/development/libraries/physics/geant4/setup-hook.sh1
6 files changed, 378 insertions, 0 deletions
diff --git a/pkgs/development/libraries/physics/geant4/default.nix b/pkgs/development/libraries/physics/geant4/default.nix
new file mode 100644
index 000000000000..54a9ad42d2d7
--- /dev/null
+++ b/pkgs/development/libraries/physics/geant4/default.nix
@@ -0,0 +1,181 @@
+{ enableMultiThreading ? false
+, enableG3toG4         ? false
+, enableInventor       ? false
+, enableGDML           ? false
+, enableQT             ? false
+, enableXM             ? false
+, enableOpenGLX11      ? false
+, enableRaytracerX11   ? false
+
+# Standard build environment with cmake.
+, stdenv, fetchurl, cmake
+
+# Optional system packages, otherwise internal GEANT4 packages are used.
+, clhep ? null
+, expat ? null
+, zlib  ? null
+
+# For enableGDML.
+, xercesc ? null
+
+# For enableQT.
+, qt ? null # qt4SDK or qt5SDK
+
+# For enableXM.
+, motif ? null # motif or lesstif
+
+# For enableQT, enableXM, enableOpenGLX11, enableRaytracerX11.
+, mesa   ? null
+, x11    ? null
+, libXmu ? null
+}:
+
+# G4persistency library with support for GDML
+assert enableGDML -> xercesc != null;
+
+# If enableQT, Qt4/5 User Interface and Visualization drivers.
+assert enableQT -> qt != null;
+
+# Motif User Interface and Visualisation drivers.
+assert enableXM -> motif != null;
+
+# OpenGL/X11 User Interface and Visualisation drivers.
+assert enableQT || enableXM || enableOpenGLX11 || enableRaytracerX11 -> mesa   != null;
+assert enableQT || enableXM || enableOpenGLX11 || enableRaytracerX11 -> x11    != null;
+assert enableQT || enableXM || enableOpenGLX11 || enableRaytracerX11 -> libXmu != null;
+
+let
+  buildGeant4 =
+    { version, src, multiThreadingCapable ? false }:
+
+    stdenv.mkDerivation rec {
+      inherit version src;
+      name = "geant4-${version}";
+
+      # The data directory holds not just interaction cross section data, but other
+      # files which the installer needs to write, so we link to the previously installed
+      # data instead. This assumes the default data installation location of $out/share.
+      preConfigure = ''
+        mkdir -p $out/share/Geant4-${version}
+        ln -s ${g4data}/Geant4-${version}/data $out/share/Geant4-${version}/data
+      '';
+
+      multiThreadingFlag = if multiThreadingCapable then "-DGEANT4_BUILD_MULTITHREADED=${if enableMultiThreading then "ON" else "OFF"}" else "";
+
+      cmakeFlags = ''
+        ${multiThreadingFlag}
+        -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"}
+        -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"}
+      '';
+
+      g4data = installData {
+        inherit version src;
+      };
+
+      enableParallelBuilding = true;
+      buildInputs = [ cmake clhep expat zlib xercesc qt motif mesa x11 libXmu ];
+      propagatedBuildInputs = [ g4data clhep expat zlib xercesc qt motif mesa x11 libXmu ];
+
+      setupHook = ./setup-hook.sh;
+
+      # Set the myriad of envars required by Geant4 if we use a nix-shell.
+      shellHook = ''
+        source $out/nix-support/setup-hook
+      '';
+
+      meta = {
+        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 = stdenv.lib.licenses.g4sl;
+        maintainers = [ ];
+        platforms = stdenv.lib.platforms.all;
+      };
+    };
+
+  installData = 
+    { version, src }:
+ 
+    stdenv.mkDerivation rec {
+      inherit version src;
+      name = "g4data-${version}";
+
+      cmakeFlags = ''
+        -DGEANT4_INSTALL_DATA="ON"
+      '';
+
+      buildInputs = [ cmake expat ];
+
+      enableParallelBuilding = true;
+      buildPhase = ''
+        make G4EMLOW G4NDL G4NEUTRONXS G4PII G4SAIDDATA PhotonEvaporation RadioactiveDecay RealSurface
+      '';
+
+      installPhase = ''
+        mkdir -p $out/Geant4-${version}
+        cp -R data/ $out/Geant4-${version}
+      '';
+
+      meta = {
+        description = "Data files for the Geant4 toolkit.";
+        homepage = http://www.geant4.org;
+        license = stdenv.lib.licenses.g4sl;
+        maintainers = [ ];
+        platforms = stdenv.lib.platforms.all;
+      };
+    }; 
+
+  fetchGeant4 = import ./fetch.nix {
+    inherit stdenv fetchurl;
+  };
+
+in {
+
+  ### VERSION 9.6
+
+  v9_6 = buildGeant4 {
+    inherit (fetchGeant4.v9_6) version src;
+  };
+
+  v9_6_1 = buildGeant4 {
+    inherit (fetchGeant4.v9_6_1) version src;
+  };
+
+  v9_6_2 = buildGeant4 {
+    inherit (fetchGeant4.v9_6_2) version src;
+  };
+
+  v9_6_3 = buildGeant4 {
+    inherit (fetchGeant4.v9_6_3) version src;
+  };
+
+  ## VERSION 10.0
+
+  v10_0 = buildGeant4 {
+    inherit (fetchGeant4.v10_0) version src;
+    multiThreadingCapable = true;
+  };
+
+  v10_0_1 = buildGeant4 {
+    inherit (fetchGeant4.v10_0_1) version src;
+    multiThreadingCapable = true;
+  };
+
+  v10_0_2 = buildGeant4 {
+    inherit (fetchGeant4.v10_0_2) version src;
+    multiThreadingCapable = true;
+  };
+} 
+ 
diff --git a/pkgs/development/libraries/physics/geant4/fetch.nix b/pkgs/development/libraries/physics/geant4/fetch.nix
new file mode 100644
index 000000000000..0c2f4b5dc544
--- /dev/null
+++ b/pkgs/development/libraries/physics/geant4/fetch.nix
@@ -0,0 +1,78 @@
+{ stdenv, fetchurl }:
+
+let
+  fetch = { version, src ? builtins.getAttr stdenv.system sources, sources ? null }:
+  {
+    inherit version src;
+  };
+
+in {
+
+  ### VERSION 9.6 
+
+  v9_6 = fetch {
+    version = "9.6";
+
+    src = fetchurl{
+      url = "http://geant4.cern.ch/support/source/geant4.9.6.tar.gz";
+      sha256 = "3b1caf87664ef35cab25563b2911653701e98c75a9bd6c64f364d1a1213247e5";
+    };  
+  };  
+
+  v9_6_1 = fetch {
+    version = "9.6.1";
+
+    src = fetchurl{
+      url = "http://geant4.cern.ch/support/source/geant4.9.6.p01.tar.gz";
+      sha256 = "575c45029afc2405d70c38e6dcfd1a752564b2540f33a922230039be81c8e4b6";
+    };  
+  };  
+
+  v9_6_2 = fetch {
+    version = "9.6.2";
+
+    src = fetchurl{
+      url = "http://geant4.cern.ch/support/source/geant4.9.6.p02.tar.gz";
+      sha256 = "cf5df83b7e2c99e6729449b32d3ecb0727b4692317426b66fc7fd41951c7351f";
+    };  
+  };  
+
+  v9_6_3 = fetch {
+    version = "9.6.3";
+
+    src = fetchurl{
+      url = "http://geant4.cern.ch/support/source/geant4.9.6.p03.tar.gz";
+      sha256 = "3a7e969039e8992716b3bc33b44cbdbff9c8d5850385f1a02fdd756a4fa6305c";
+    };  
+  };  
+
+  ### Version 10.0
+
+  v10_0 = fetch {
+    version = "10.0";
+
+    src = fetchurl{
+      url = "http://geant4.cern.ch/support/source/geant4.10.00.tar.gz";
+      sha256 = "ffec1714b03748b6d691eb0b91906f4c74422c1ad1f8afa918e03be421af8a17";
+    };  
+  };  
+
+  v10_0_1 = fetch {
+    version = "10.0.1";
+
+    src = fetchurl{
+      url = "http://geant4.cern.ch/support/source/geant4.10.00.p01.tar.gz";
+      sha256 = "09c431ff3ef81034282c46501cea01046d4a20438c2ea2a7339576e1ecf26ba0";
+    };  
+  };  
+
+  v10_0_2 = fetch {
+    version = "10.0.2";
+
+    src = fetchurl{
+      url = "http://geant4.cern.ch/support/source/geant4.10.00.p02.tar.gz";
+      sha256 = "9d615200901f1a5760970e8f5970625ea146253e4f7c5ad9df2a9cf84549e848";
+    };  
+  };
+}
+
diff --git a/pkgs/development/libraries/physics/geant4/g4py/configure.patch b/pkgs/development/libraries/physics/geant4/g4py/configure.patch
new file mode 100644
index 000000000000..886618abd34a
--- /dev/null
+++ b/pkgs/development/libraries/physics/geant4/g4py/configure.patch
@@ -0,0 +1,12 @@
+--- environments/g4py/configure	2014-03-17 22:47:05.000000000 +1100
++++ environments/g4py/configure	2014-09-01 15:33:46.523637686 +1000
+@@ -4,9 +4,6 @@
+ # ======================================================================
+ export LANG=C
+ 
+-PATH=/bin:/usr/bin
+-export PATH
+-
+ # ======================================================================
+ # testing the echo features
+ # ======================================================================
diff --git a/pkgs/development/libraries/physics/geant4/g4py/default.nix b/pkgs/development/libraries/physics/geant4/g4py/default.nix
new file mode 100644
index 000000000000..f6ca6562b6fe
--- /dev/null
+++ b/pkgs/development/libraries/physics/geant4/g4py/default.nix
@@ -0,0 +1,105 @@
+{ stdenv, fetchurl
+
+# The target version of Geant4
+, geant4
+
+# Python (obviously) and boost::python for wrapping.
+, python
+, boost
+}:
+
+let
+  buildG4py = 
+    { version, src, geant4}:
+
+    stdenv.mkDerivation rec {
+      inherit version src geant4;
+      name = "g4py-${version}";
+
+      # ./configure overwrites $PATH, which clobbers everything.
+      patches = [ ./configure.patch ];
+      patchFlags = "-p0";
+
+      configurePhase = ''
+        export PYTHONPATH=$PYTHONPATH:${geant4}/lib64:$prefix
+
+        source ${geant4}/share/Geant4-*/geant4make/geant4make.sh
+        cd environments/g4py
+
+        ./configure linux64 --prefix=$prefix \
+                            --with-g4install-dir=${geant4} \
+                            --with-python-incdir=${python}/include/python${python.majorVersion} \
+                            --with-python-libdir=${python}/lib \
+                            --with-boost-incdir=${boost}/include \
+                            --with-boost-libdir=${boost}/lib
+      '';
+
+      enableParallelBuilding = true;
+      buildInputs = [ geant4 boost python ];
+
+      setupHook = ./setup-hook.sh;
+
+      # Make sure we set PYTHONPATH
+      shellHook = ''
+        source $out/nix-support/setup-hook
+      '';
+
+      meta = {
+        description = "Python bindings and utilities for Geant4.";
+        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 = stdenv.lib.licenses.g4sl;
+        maintainers = [ ];
+        platforms = stdenv.lib.platforms.all;
+      }; 
+    };
+
+    fetchGeant4 = import ../fetch.nix {
+      inherit stdenv fetchurl;
+    };  
+
+in {
+
+  ### VERSION 9.6 
+
+  v9_6 = buildG4py {
+    inherit (fetchGeant4.v9_6) version src;
+    geant4 = geant4.v9_6;
+  };  
+
+  v9_6_1 = buildG4py {
+    inherit (fetchGeant4.v9_6_1) version src;
+    geant4 = geant4.v9_6_1;
+  };  
+
+  v9_6_2 = buildG4py {
+    inherit (fetchGeant4.v9_6_2) version src;
+    geant4 = geant4.v9_6_2;
+  };  
+
+  v9_6_3 = buildG4py {
+    inherit (fetchGeant4.v9_6_3) version src;
+    geant4 = geant4.v9_6_3;
+  };  
+
+  ## VERSION 10.0
+
+  v10_0 = buildG4py {
+    inherit (fetchGeant4.v10_0) version src;
+    geant4 = geant4.v10_0;
+  };  
+
+  v10_0_1 = buildG4py {
+    inherit (fetchGeant4.v10_0_1) version src;
+    geant4 = geant4.v10_0_1;
+  };  
+
+  v10_0_2 = buildG4py {
+    inherit (fetchGeant4.v10_0_2) version src;
+    geant4 = geant4.v10_0_2;
+  };  
+} 
diff --git a/pkgs/development/libraries/physics/geant4/g4py/setup-hook.sh b/pkgs/development/libraries/physics/geant4/g4py/setup-hook.sh
new file mode 100644
index 000000000000..8abfb461fc0f
--- /dev/null
+++ b/pkgs/development/libraries/physics/geant4/g4py/setup-hook.sh
@@ -0,0 +1 @@
+export PYTHONPATH=$PYTHONPATH:@out@/lib
diff --git a/pkgs/development/libraries/physics/geant4/setup-hook.sh b/pkgs/development/libraries/physics/geant4/setup-hook.sh
new file mode 100644
index 000000000000..0b775d432831
--- /dev/null
+++ b/pkgs/development/libraries/physics/geant4/setup-hook.sh
@@ -0,0 +1 @@
+source @out@/bin/geant4.sh