Merge pull request #179719 from veprbl/pr/geant4_dep_rework

geant4: adjust dependency handling, use callPackage for geant4.data
This commit is contained in:
Dmitry Kalinkin 2022-07-06 23:03:11 -04:00 committed by GitHub
commit 99b11e4c97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 28 deletions

View File

@ -1,10 +1,10 @@
{ lib, stdenv, fetchurl, geant_version }:
{ lib, stdenv, fetchurl, geant4 }:
let
mkDataset = { pname, version, sha256, envvar }:
stdenv.mkDerivation {
inherit pname version;
inherit geant_version;
geant_version = geant4.version;
src = fetchurl {
url = "https://cern.ch/geant4-data/datasets/${pname}.${version}.tar.gz";
@ -15,7 +15,7 @@ let
dontBuild = true;
dontConfigure = true;
datadir = "${placeholder "out"}/share/Geant4-${geant_version}/data/${pname}${version}";
datadir = "${placeholder "out"}/share/Geant4-${geant4.version}/data/${pname}${version}";
installPhase = ''
mkdir -p $datadir
mv ./* $datadir

View File

@ -1,8 +1,7 @@
{ enableMultiThreading ? true
, enableG3toG4 ? false
, enableInventor ? false
, enableGDML ? false
, enableQT ? false
, enableQT ? false # deprecated name
, enableQt ? enableQT
, enableXM ? false
, enableOpenGLX11 ? true
, enablePython ? false
@ -11,15 +10,12 @@
# Standard build environment with cmake.
, lib, stdenv, fetchurl, fetchpatch, cmake
# Optional system packages, otherwise internal GEANT4 packages are used.
, clhep ? null # not packaged currently
, expat
, xercesc
, zlib
# For enableGDML.
, xercesc
# For enableQT.
# For enableQt.
, qtbase
, wrapQtAppsHook
@ -31,7 +27,7 @@
, soxt
, libXpm
# For enableQT, enableXM, enableOpenGLX11, enableRaytracerX11.
# For enableQt, enableXM, enableOpenGLX11, enableRaytracerX11.
, libGLU, libGL
, xlibsWrapper
, libXmu
@ -48,6 +44,8 @@ let
boost_python = boost.override { enablePython = true; python = python3; };
in
lib.warnIf (enableQT != false) "geant4: enableQT is deprecated, please use enableQt"
stdenv.mkDerivation rec {
version = "11.0.0";
pname = "geant4";
@ -59,17 +57,17 @@ stdenv.mkDerivation rec {
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_GDML=ON"
"-DGEANT4_USE_G3TOG4=ON"
"-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_PYTHON=${if enablePython 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_USE_SYSTEM_EXPAT=ON"
"-DGEANT4_USE_SYSTEM_ZLIB=ON"
"-DGEANT4_BUILD_MULTITHREADED=${if enableMultiThreading then "ON" else "OFF"}"
] ++ lib.optionals stdenv.isDarwin [
"-DXQuartzGL_INCLUDE_DIR=${libGL.dev}/include"
@ -83,37 +81,36 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [
cmake
] ++ lib.optionals enableQT [
wrapQtAppsHook
];
dontWrapQtApps = !enableQT;
propagatedNativeBuildInputs = lib.optionals enableQt [
wrapQtAppsHook
];
dontWrapQtApps = true; # no binaries
buildInputs = [ libGLU xlibsWrapper libXmu ]
++ lib.optionals enableInventor [ libXpm coin3d soxt motif ]
++ lib.optionals enablePython [ boost_python python3 ];
propagatedBuildInputs = [ clhep expat zlib libGL ]
++ lib.optionals enableGDML [ xercesc ]
propagatedBuildInputs = [ clhep expat xercesc zlib libGL ]
++ lib.optionals enableXM [ motif ]
++ lib.optionals enableQT [ qtbase ];
++ lib.optionals enableQt [ qtbase ];
postFixup = ''
# Don't try to export invalid environment variables.
sed -i 's/export G4\([A-Z]*\)DATA/#export G4\1DATA/' "$out"/bin/geant4.sh
'' + lib.optionalString enableQT ''
'' + lib.optionalString enableQt ''
wrapQtAppsHook
'';
setupHook = ./geant4-hook.sh;
passthru = {
data = import ./datasets.nix {
inherit lib stdenv fetchurl;
geant_version = version;
};
data = callPackage ./datasets.nix {};
tests = callPackage ./tests.nix {};
inherit enableQt;
};
# Set the myriad of envars required by Geant4 if we use a nix-shell.