geant4: move to by-name, drop deprecated enableQT argument (#358781)

This commit is contained in:
Dmitry Kalinkin 2024-11-26 12:33:48 -05:00 committed by GitHub
parent fd55f1875e
commit 62e97383c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 297 additions and 265 deletions

View File

@ -0,0 +1,137 @@
{
lib,
stdenv,
fetchurl,
geant4,
}:
let
mkDataset =
{
pname,
version,
sha256,
envvar,
}:
stdenv.mkDerivation {
inherit pname version;
geant_version = geant4.version;
src = fetchurl {
url = "https://cern.ch/geant4-data/datasets/${pname}.${version}.tar.gz";
inherit sha256;
};
preferLocalBuild = true;
dontBuild = true;
dontConfigure = true;
datadir = "${placeholder "out"}/share/Geant4-${geant4.version}/data/${pname}${version}";
installPhase = ''
mkdir -p $datadir
mv ./* $datadir
'';
inherit envvar;
setupHook = ./datasets-hook.sh;
meta = with lib; {
description = "Data files for the Geant4 toolkit";
homepage = "https://geant4.web.cern.ch/support/download";
license = licenses.g4sl;
platforms = platforms.all;
};
};
in
builtins.listToAttrs (
map
(a: {
name = a.pname;
value = mkDataset a;
})
[
{
pname = "G4NDL";
version = "4.7.1";
sha256 = "sha256-06yuSGIhGNJXneJKVNUz+yQWvw2p3SiPFyTfFIWkbHw=";
envvar = "NEUTRONHP";
}
{
pname = "G4EMLOW";
version = "8.5";
sha256 = "sha256-ZrrKSaxdReKsEMEltPsmYiXlEYA+ZpgZCc6c0+m873M=";
envvar = "LE";
}
{
pname = "G4PhotonEvaporation";
version = "5.7";
sha256 = "sha256-dh5C5W/93j2YOfn52BAmB8a0wDKRUe5Rggb07p535+U=";
envvar = "LEVELGAMMA";
}
{
pname = "G4RadioactiveDecay";
version = "5.6";
sha256 = "sha256-OIYHfJyOWph4PmcY4cMlZ4me6y27M+QC1Edrwv5PDfE=";
envvar = "RADIOACTIVE";
}
{
pname = "G4SAIDDATA";
version = "2.0";
sha256 = "sha256-HSao55uqceRNV1m59Vpn6Lft4xdRMWqekDfYAJDHLpE=";
envvar = "SAIDXS";
}
{
pname = "G4PARTICLEXS";
version = "4.0";
sha256 = "sha256-k4EDlwPD8rD9NqtJmTYqLItP+QgMMi+QtOMZKBEzypU=";
envvar = "PARTICLEXS";
}
{
pname = "G4ABLA";
version = "3.3";
sha256 = "sha256-HgQbMlLunO+IbWJPdT5pMwOqMtfl7zu6h7NPNtkuorE=";
envvar = "ABLA";
}
{
pname = "G4INCL";
version = "1.2";
sha256 = "sha256-+ICxYHPuCpLXSU8ydqbVLU3h02d6DUx8WHADlu0OGn4=";
envvar = "INCL";
}
{
pname = "G4PII";
version = "1.3";
sha256 = "sha256-YiWtkCZ19DgcmMa6JfxaBs6HVJqpeWNNPQNJHWYW6SY=";
envvar = "PII";
}
{
pname = "G4ENSDFSTATE";
version = "2.3";
sha256 = "sha256-lETF4IIHkavTzKrOEFsOR3kPrc4obhEUmDTnnEqOkgM=";
envvar = "ENSDFSTATE";
}
{
pname = "G4RealSurface";
version = "2.2";
sha256 = "sha256-mVTe4AEvUzEmf3g2kOkS5y21v1Lqm6vs0S6iIoIXaCA=";
envvar = "REALSURFACE";
}
{
pname = "G4TENDL";
version = "1.4";
sha256 = "sha256-S3J0AgzItO1Wm4ku8YwuCI7c22tm850lWFzO4l2XIeA=";
envvar = "PARTICLEHP";
}
]
)

View File

@ -0,0 +1,155 @@
{
lib,
stdenv,
fetchurl,
callPackage,
boost,
clhep,
cmake,
coin3d,
expat,
libGL,
libGLU,
libGLX,
libXext,
libXmu,
libXpm,
motif,
python3,
qt5,
soxt,
xercesc,
zlib,
enableMultiThreading ? true,
enableInventor ? false,
enableQt ? false,
enableXM ? false,
enableOpenGLX11 ? !stdenv.hostPlatform.isDarwin,
enablePython ? false,
enableRaytracerX11 ? false,
}:
let
boost_python = boost.override {
enablePython = true;
python = python3;
};
in
stdenv.mkDerivation rec {
version = "11.2.2";
pname = "geant4";
src = fetchurl {
url = "https://cern.ch/geant4-data/releases/geant4-v${version}.tar.gz";
hash = "sha256-0k9lc1uKCgOcAPlDSZHpnvEZuGxRDQ8qshFV24KjSR0=";
};
# Fix broken paths in a .pc
postPatch = ''
substituteInPlace source/externals/ptl/cmake/Modules/PTLPackageConfigHelpers.cmake \
--replace '${"$"}{prefix}/${"$"}{PTL_INSTALL_' '${"$"}{PTL_INSTALL_'
'';
cmakeFlags =
[
"-DGEANT4_INSTALL_DATA=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=ON"
"-DGEANT4_USE_SYSTEM_EXPAT=ON"
"-DGEANT4_USE_SYSTEM_ZLIB=ON"
"-DGEANT4_BUILD_MULTITHREADED=${if enableMultiThreading then "ON" else "OFF"}"
]
++ lib.optionals (enableOpenGLX11 && stdenv.hostPlatform.isDarwin) [
"-DXQuartzGL_INCLUDE_DIR=${libGLX.dev}/include"
"-DXQuartzGL_gl_LIBRARY=${libGLX}/lib/libGL.dylib"
]
++ lib.optionals (enableMultiThreading && enablePython) [
"-DGEANT4_BUILD_TLS_MODEL=global-dynamic"
]
++ lib.optionals enableInventor [
"-DINVENTOR_INCLUDE_DIR=${coin3d}/include"
"-DINVENTOR_LIBRARY_RELEASE=${coin3d}/lib/libCoin.so"
];
nativeBuildInputs = [ cmake ];
propagatedNativeBuildInputs = lib.optionals enableQt [ qt5.wrapQtAppsHook ];
dontWrapQtApps = true; # no binaries
buildInputs =
lib.optionals enableOpenGLX11 [
libGLU
libXext
libXmu
]
++ lib.optionals enableInventor [
libXpm
coin3d
soxt
motif
]
++ lib.optionals enablePython [
boost_python
python3
];
propagatedBuildInputs =
[
clhep
expat
xercesc
zlib
]
++ lib.optionals enableOpenGLX11 [ libGL ]
++ lib.optionals enableXM [ motif ]
++ lib.optionals enableQt [ qt5.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 ''
wrapQtAppsHook
'';
setupHook = ./geant4-hook.sh;
passthru = {
data = callPackage ./datasets.nix { };
tests = callPackage ./tests.nix { };
inherit enableQt;
};
# Set the myriad of envars required by Geant4 if we use a nix-shell.
shellHook = ''
source $out/nix-support/setup-hook
'';
meta = with lib; {
broken = (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64);
description = "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; [
omnipotententity
veprbl
];
platforms = platforms.unix;
};
}

View File

@ -1,4 +1,8 @@
{ stdenv, cmake, geant4 }:
{
stdenv,
cmake,
geant4,
}:
{
example_B1 = stdenv.mkDerivation {

View File

@ -1,119 +0,0 @@
{ lib, stdenv, fetchurl, geant4 }:
let
mkDataset = { pname, version, sha256, envvar }:
stdenv.mkDerivation {
inherit pname version;
geant_version = geant4.version;
src = fetchurl {
url = "https://cern.ch/geant4-data/datasets/${pname}.${version}.tar.gz";
inherit sha256;
};
preferLocalBuild = true;
dontBuild = true;
dontConfigure = true;
datadir = "${placeholder "out"}/share/Geant4-${geant4.version}/data/${pname}${version}";
installPhase = ''
mkdir -p $datadir
mv ./* $datadir
'';
inherit envvar;
setupHook = ./datasets-hook.sh;
meta = with lib; {
description = "Data files for the Geant4 toolkit";
homepage = "https://geant4.web.cern.ch/support/download";
license = licenses.g4sl;
platforms = platforms.all;
};
};
in
builtins.listToAttrs (map (a: { name = a.pname; value = mkDataset a; }) [
{
pname = "G4NDL";
version = "4.7.1";
sha256 = "sha256-06yuSGIhGNJXneJKVNUz+yQWvw2p3SiPFyTfFIWkbHw=";
envvar = "NEUTRONHP";
}
{
pname = "G4EMLOW";
version = "8.5";
sha256 = "sha256-ZrrKSaxdReKsEMEltPsmYiXlEYA+ZpgZCc6c0+m873M=";
envvar = "LE";
}
{
pname = "G4PhotonEvaporation";
version = "5.7";
sha256 = "sha256-dh5C5W/93j2YOfn52BAmB8a0wDKRUe5Rggb07p535+U=";
envvar = "LEVELGAMMA";
}
{
pname = "G4RadioactiveDecay";
version = "5.6";
sha256 = "sha256-OIYHfJyOWph4PmcY4cMlZ4me6y27M+QC1Edrwv5PDfE=";
envvar = "RADIOACTIVE";
}
{
pname = "G4SAIDDATA";
version = "2.0";
sha256 = "sha256-HSao55uqceRNV1m59Vpn6Lft4xdRMWqekDfYAJDHLpE=";
envvar = "SAIDXS";
}
{
pname = "G4PARTICLEXS";
version = "4.0";
sha256 = "sha256-k4EDlwPD8rD9NqtJmTYqLItP+QgMMi+QtOMZKBEzypU=";
envvar = "PARTICLEXS";
}
{
pname = "G4ABLA";
version = "3.3";
sha256 = "sha256-HgQbMlLunO+IbWJPdT5pMwOqMtfl7zu6h7NPNtkuorE=";
envvar = "ABLA";
}
{
pname = "G4INCL";
version = "1.2";
sha256 = "sha256-+ICxYHPuCpLXSU8ydqbVLU3h02d6DUx8WHADlu0OGn4=";
envvar = "INCL";
}
{
pname = "G4PII";
version = "1.3";
sha256 = "sha256-YiWtkCZ19DgcmMa6JfxaBs6HVJqpeWNNPQNJHWYW6SY=";
envvar = "PII";
}
{
pname = "G4ENSDFSTATE";
version = "2.3";
sha256 = "sha256-lETF4IIHkavTzKrOEFsOR3kPrc4obhEUmDTnnEqOkgM=";
envvar = "ENSDFSTATE";
}
{
pname = "G4RealSurface";
version = "2.2";
sha256 = "sha256-mVTe4AEvUzEmf3g2kOkS5y21v1Lqm6vs0S6iIoIXaCA=";
envvar = "REALSURFACE";
}
{
pname = "G4TENDL";
version = "1.4";
sha256 = "sha256-S3J0AgzItO1Wm4ku8YwuCI7c22tm850lWFzO4l2XIeA=";
envvar = "PARTICLEHP";
}
])

View File

@ -1,143 +0,0 @@
{ enableMultiThreading ? true
, enableInventor ? false
, enableQT ? false # deprecated name
, enableQt ? enableQT
, enableXM ? false
, libGLX
, enableOpenGLX11 ? !stdenv.hostPlatform.isDarwin
, enablePython ? false
, enableRaytracerX11 ? false
# Standard build environment with cmake.
, lib, stdenv, fetchurl, cmake
, clhep
, expat
, xercesc
, zlib
# For enableQt.
, qtbase
, wrapQtAppsHook
# For enableXM.
, motif
# For enableInventor
, coin3d
, soxt
, libXpm
# For enableQt, enableXM, enableOpenGLX11, enableRaytracerX11.
, libGLU, libGL
, libXext
, libXmu
# For enablePython
, boost
, python3
# For tests
, callPackage
}:
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.2.2";
pname = "geant4";
src = fetchurl {
url = "https://cern.ch/geant4-data/releases/geant4-v${version}.tar.gz";
hash = "sha256-0k9lc1uKCgOcAPlDSZHpnvEZuGxRDQ8qshFV24KjSR0=";
};
# Fix broken paths in a .pc
postPatch = ''
substituteInPlace source/externals/ptl/cmake/Modules/PTLPackageConfigHelpers.cmake \
--replace '${"$"}{prefix}/${"$"}{PTL_INSTALL_' '${"$"}{PTL_INSTALL_'
'';
cmakeFlags = [
"-DGEANT4_INSTALL_DATA=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=ON"
"-DGEANT4_USE_SYSTEM_EXPAT=ON"
"-DGEANT4_USE_SYSTEM_ZLIB=ON"
"-DGEANT4_BUILD_MULTITHREADED=${if enableMultiThreading then "ON" else "OFF"}"
] ++ lib.optionals (enableOpenGLX11 && stdenv.hostPlatform.isDarwin) [
"-DXQuartzGL_INCLUDE_DIR=${libGLX.dev}/include"
"-DXQuartzGL_gl_LIBRARY=${libGLX}/lib/libGL.dylib"
] ++ lib.optionals (enableMultiThreading && enablePython) [
"-DGEANT4_BUILD_TLS_MODEL=global-dynamic"
] ++ lib.optionals enableInventor [
"-DINVENTOR_INCLUDE_DIR=${coin3d}/include"
"-DINVENTOR_LIBRARY_RELEASE=${coin3d}/lib/libCoin.so"
];
nativeBuildInputs = [
cmake
];
propagatedNativeBuildInputs = lib.optionals enableQt [
wrapQtAppsHook
];
dontWrapQtApps = true; # no binaries
buildInputs =
lib.optionals enableOpenGLX11 [ libGLU libXext libXmu ]
++ lib.optionals enableInventor [ libXpm coin3d soxt motif ]
++ lib.optionals enablePython [ boost_python python3 ];
propagatedBuildInputs = [ clhep expat xercesc zlib ]
++ lib.optionals enableOpenGLX11 [ libGL ]
++ lib.optionals enableXM [ motif ]
++ 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 ''
wrapQtAppsHook
'';
setupHook = ./geant4-hook.sh;
passthru = {
data = callPackage ./datasets.nix {};
tests = callPackage ./tests.nix {};
inherit enableQt;
};
# Set the myriad of envars required by Geant4 if we use a nix-shell.
shellHook = ''
source $out/nix-support/setup-hook
'';
meta = with lib; {
broken = (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64);
description = "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; [ omnipotententity veprbl ];
platforms = platforms.unix;
};
}

View File

@ -18068,8 +18068,6 @@ with pkgs;
inherit (darwin.apple_sdk.frameworks) Cocoa;
};
geant4 = libsForQt5.callPackage ../development/libraries/physics/geant4 { };
hepmc3 = callPackage ../development/libraries/physics/hepmc3 {
python = null;
};