From 537de20645479f49d64a6021a062850a3b4d6d64 Mon Sep 17 00:00:00 2001
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Date: Wed, 16 May 2018 17:09:07 -0400
Subject: [PATCH] geant4: remove multi version infrastructure

Nobody maintains this and this does not contribute anything towards
making reproducible research. Also this was missing recurseIntoAttrs, so
Hydra used to not see it.
---
 .../libraries/physics/geant4/default.nix      | 130 ++++++++----------
 .../libraries/physics/geant4/fetch.nix        |  29 ----
 .../libraries/physics/geant4/g4py/default.nix |  93 ++++++-------
 3 files changed, 96 insertions(+), 156 deletions(-)
 delete mode 100644 pkgs/development/libraries/physics/geant4/fetch.nix

diff --git a/pkgs/development/libraries/physics/geant4/default.nix b/pkgs/development/libraries/physics/geant4/default.nix
index e80277ec044..2130e3feffa 100644
--- a/pkgs/development/libraries/physics/geant4/default.nix
+++ b/pkgs/development/libraries/physics/geant4/default.nix
@@ -50,83 +50,67 @@ assert enableQT || enableXM || enableOpenGLX11 || enableRaytracerX11 -> xlibsWra
 assert enableQT || enableXM || enableOpenGLX11 || enableRaytracerX11 -> libXmu != null;
 assert enableInventor -> libXpm != null;
 
-let
-  buildGeant4 =
-    { version, src, multiThreadingCapable ? false }:
+stdenv.mkDerivation rec {
+  version = "10.4.1";
+  name = "geant4-${version}";
 
-    stdenv.mkDerivation rec {
-      inherit version src;
-      name = "geant4-${version}";
-
-      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"}"
-        "-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"}"
-      ] ++ stdenv.lib.optional multiThreadingCapable
-        "-DGEANT4_BUILD_MULTITHREADED=${if enableMultiThreading then "ON" else "OFF"}"
-        ++ stdenv.lib.optionals enableInventor [
-        "-DINVENTOR_INCLUDE_DIR=${coin3d}/include"
-        "-DINVENTOR_LIBRARY_RELEASE=${coin3d}/lib/libCoin.so"
-      ];
-
-      enableParallelBuilding = true;
-      nativeBuildInputs =  [ cmake ];
-      buildInputs = [ clhep expat zlib libGLU_combined xlibsWrapper libXmu ]
-        ++ stdenv.lib.optionals enableGDML [ xercesc ]
-        ++ stdenv.lib.optionals enableXM [ motif ]
-        ++ stdenv.lib.optionals enableQT [ qt ]
-        ++ stdenv.lib.optionals enableInventor [ libXpm coin3d soxt ];
-
-      postFixup = ''
-        # Don't try to export invalid environment variables.
-        sed -i 's/export G4\([A-Z]*\)DATA/#export G4\1DATA/' "$out"/bin/geant4.sh
-      '';
-
-      setupHook = ./geant4-hook.sh;
-
-      passthru = {
-        data = import ./datasets.nix { inherit stdenv fetchurl; };
-      };
-
-      # Set the myriad of envars required by Geant4 if we use a nix-shell.
-      shellHook = ''
-        source $out/nix-support/setup-hook
-      '';
-
-      meta = with stdenv.lib; {
-        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;
-        maintainers = with maintainers; [ tmplt ];
-        platforms = platforms.all;
-      };
-    };
-
-  fetchGeant4 = import ./fetch.nix {
-    inherit stdenv fetchurl;
+  src = fetchurl{
+    url = "http://cern.ch/geant4-data/releases/geant4.10.04.p01.tar.gz";
+    sha256 = "a3eb13e4f1217737b842d3869dc5b1fb978f761113e74bd4eaf6017307d234dd";
   };
 
-in {
-  v10_0_2 = buildGeant4 {
-    inherit (fetchGeant4.v10_0_2) version src;
-    multiThreadingCapable = true;
+  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"}"
+    "-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"}"
+  ] ++ stdenv.lib.optionals enableInventor [
+    "-DINVENTOR_INCLUDE_DIR=${coin3d}/include"
+    "-DINVENTOR_LIBRARY_RELEASE=${coin3d}/lib/libCoin.so"
+  ];
+
+  enableParallelBuilding = true;
+  nativeBuildInputs =  [ cmake ];
+  buildInputs = [ clhep expat zlib libGLU_combined xlibsWrapper libXmu ]
+    ++ stdenv.lib.optionals enableGDML [ xercesc ]
+    ++ stdenv.lib.optionals enableXM [ motif ]
+    ++ stdenv.lib.optionals enableQT [ qt ]
+    ++ stdenv.lib.optionals enableInventor [ libXpm coin3d soxt ];
+
+  postFixup = ''
+    # Don't try to export invalid environment variables.
+    sed -i 's/export G4\([A-Z]*\)DATA/#export G4\1DATA/' "$out"/bin/geant4.sh
+  '';
+
+  setupHook = ./geant4-hook.sh;
+
+  passthru = {
+    data = import ./datasets.nix { inherit stdenv fetchurl; };
   };
 
-  v10_4_1 = buildGeant4 {
-    inherit (fetchGeant4.v10_4_1) version src;
-    multiThreadingCapable = true;
+  # Set the myriad of envars required by Geant4 if we use a nix-shell.
+  shellHook = ''
+    source $out/nix-support/setup-hook
+  '';
+
+  meta = with stdenv.lib; {
+    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;
+    maintainers = with maintainers; [ tmplt ];
+    platforms = platforms.all;
   };
 }
diff --git a/pkgs/development/libraries/physics/geant4/fetch.nix b/pkgs/development/libraries/physics/geant4/fetch.nix
deleted file mode 100644
index 5d539b480d7..00000000000
--- a/pkgs/development/libraries/physics/geant4/fetch.nix
+++ /dev/null
@@ -1,29 +0,0 @@
-{ stdenv, fetchurl }:
-
-let
-  fetch = { version, src ? builtins.getAttr stdenv.hostPlatform.system sources, sources ? null }:
-  {
-    inherit version src;
-  };
-
-in {
-  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";
-    };
-  };
-
-  v10_4_1 = fetch {
-    version = "10.4.1";
-
-    src = fetchurl{
-      url = "http://cern.ch/geant4-data/releases/geant4.10.04.p01.tar.gz";
-      sha256 = "a3eb13e4f1217737b842d3869dc5b1fb978f761113e74bd4eaf6017307d234dd";
-    };
-  };
-
-}
-
diff --git a/pkgs/development/libraries/physics/geant4/g4py/default.nix b/pkgs/development/libraries/physics/geant4/g4py/default.nix
index ee332171158..8d6dfdca47d 100644
--- a/pkgs/development/libraries/physics/geant4/g4py/default.nix
+++ b/pkgs/development/libraries/physics/geant4/g4py/default.nix
@@ -8,67 +8,52 @@
 , boost
 }:
 
-let
-  buildG4py = 
-    { version, src, geant4}:
+stdenv.mkDerivation rec {
+  inherit (geant4) version src;
+  name = "g4py-${version}";
 
-    stdenv.mkDerivation rec {
-      inherit version src geant4;
-      name = "g4py-${version}";
+  # ./configure overwrites $PATH, which clobbers everything.
+  patches = [ ./configure.patch ];
+  patchFlags = "-p0";
 
-      # ./configure overwrites $PATH, which clobbers everything.
-      patches = [ ./configure.patch ];
-      patchFlags = "-p0";
+  configurePhase = ''
+    export PYTHONPATH=$PYTHONPATH:${geant4}/lib64:$prefix
 
-      configurePhase = ''
-        export PYTHONPATH=$PYTHONPATH:${geant4}/lib64:$prefix
+    source ${geant4}/share/Geant4-*/geant4make/geant4make.sh
+    cd environments/g4py
 
-        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.dev}/include \
+                        --with-boost-libdir=${boost.out}/lib
+  '';
 
-        ./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.dev}/include \
-                            --with-boost-libdir=${boost.out}/lib
-      '';
+  enableParallelBuilding = true;
+  buildInputs = [ geant4 boost python ];
 
-      enableParallelBuilding = true;
-      buildInputs = [ geant4 boost python ];
+  setupHook = ./setup-hook.sh;
 
-      setupHook = ./setup-hook.sh;
+  # Make sure we set PYTHONPATH
+  shellHook = ''
+    source $out/nix-support/setup-hook
+  '';
 
-      # 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 {
-  v10_0_2 = buildG4py {
-    inherit (fetchGeant4.v10_0_2) version src;
-    geant4 = geant4.v10_0_2;
+  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;
   };
 }