Files
2026-05-29 12:03:24 +01:00

244 lines
5.0 KiB
Nix

{
stdenv,
lib,
blas,
callPackage,
curl,
fetchFromGitHub,
fetchurl,
makeWrapper,
writeText,
apple-sdk,
cmake,
coreutils,
git,
davix,
fftw,
ftgl,
gl2ps,
gnugrep,
gnused,
gsl,
libGLU,
libGL,
libxcrypt,
libxml2,
llvm_20,
lsof,
lz4,
libxpm,
libxft,
libxext,
libx11,
xz,
man,
openssl,
pcre2,
nlohmann_json,
pkg-config,
procps,
python3,
which,
xxhash,
zlib,
zstd,
giflib,
libjpeg,
libtiff,
libpng,
patchRcPathCsh,
patchRcPathFish,
patchRcPathPosix,
onetbb,
xrootd,
freetype,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "root";
version = "6.40.00";
passthru = {
tests = import ./tests { inherit callPackage; };
};
src = fetchurl {
url = "https://root.cern.ch/download/root_v${finalAttrs.version}.source.tar.gz";
hash = "sha256-Z2+P3okmzgWQK+f0TOfUkqSiBgAi/KsOPRxE9twPveg=";
};
clad_src = fetchFromGitHub {
owner = "vgvassilev";
repo = "clad";
# Make sure that this is the same tag as in the ROOT build files!
# https://github.com/root-project/root/blob/master/interpreter/cling/tools/plugins/clad/CMakeLists.txt#L76
tag = "v2.3";
hash = "sha256-gEJlQ2Vg9EUX1tslI4HaUnusvdSomsYHiE8mZMygEOw=";
};
# ROOT requires a patched version of clang
clang = (callPackage ./clang-root.nix { });
nativeBuildInputs = [
makeWrapper
cmake
pkg-config
git
];
propagatedBuildInputs = [
nlohmann_json # link interface of target "ROOT::ROOTEve"
];
buildInputs = [
finalAttrs.clang
blas
curl
davix
fftw
ftgl
giflib
gl2ps
gsl
libjpeg
libpng
libtiff
libxcrypt
libxml2
llvm_20
lz4
openssl
patchRcPathCsh
patchRcPathFish
patchRcPathPosix
pcre2
python3
onetbb
xrootd
xxhash
xz
zlib
zstd
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
apple-sdk.privateFrameworksHook
freetype
]
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
libGLU
libGL
libx11
libxpm
libxft
libxext
];
preConfigure = ''
for path in builtins/*; do
if [[ "$path" != "builtins/openui5" ]] && [[ "$path" != "builtins/rendercore" ]]; then
rm -rf "$path"
fi
done
substituteInPlace cmake/modules/SearchInstalledSoftware.cmake \
--replace-fail 'set(lcgpackages ' '#set(lcgpackages '
patchShebangs cmake/unix/
''
+
lib.optionalString
(stdenv.hostPlatform.isDarwin && lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11")
''
MACOSX_DEPLOYMENT_TARGET=10.16
'';
cmakeFlags = [
"-DCLAD_SOURCE_DIR=${finalAttrs.clad_src}"
"-DClang_DIR=${finalAttrs.clang}/lib/cmake/clang"
"-Dbuiltin_clang=OFF"
"-Dbuiltin_llvm=OFF"
"-Dfail-on-missing=ON"
"-Dfftw3=ON"
"-Dfitsio=OFF"
"-Dmathmore=ON"
"-Dsqlite=OFF"
"-Dvdt=OFF"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
# fatal error: module map file '/nix/store/<hash>-Libsystem-osx-10.12.6/include/module.modulemap' not found
# fatal error: could not build module '_Builtin_intrinsics'
"-Druntime_cxxmodules=OFF"
];
postInstall = ''
for prog in rooteventselector rootmv rootprint rootslimtree; do
wrapProgram "$out/bin/$prog" \
--set PYTHONPATH "$out/lib"
done
# Make ldd and sed available to the ROOT executable by prefixing PATH.
wrapProgram "$out/bin/root" \
--prefix PATH : "${
lib.makeBinPath [
gnused # sed
stdenv.cc # c++ ld etc.
stdenv.cc.libc # ldd
]
}"
# Patch thisroot.{sh,csh,fish}
# The main target of `thisroot.sh` is "bash-like shells",
# but it also need to support Bash-less POSIX shell like dash,
# as they are mentioned in `thisroot.sh`.
patchRcPathPosix "$out/bin/thisroot.sh" "${
lib.makeBinPath [
coreutils # dirname tail
gnugrep # grep
gnused # sed
lsof # lsof
man # manpath
procps # ps
which # which
]
}"
patchRcPathCsh "$out/bin/thisroot.csh" "${
lib.makeBinPath [
coreutils
gnugrep
gnused
lsof # lsof
man
which
]
}"
patchRcPathFish "$out/bin/thisroot.fish" "${
lib.makeBinPath [
coreutils
man
which
]
}"
'';
# To use the debug information on the fly (without installation)
# add the outPath of root.debug into NIX_DEBUG_INFO_DIRS (in PATH-like format)
# and make sure that gdb from Nixpkgs can be found in PATH.
#
# Darwin currently fails to support it (#203380)
# we set it to true hoping to benefit from the future fix.
# Before that, please make sure if root.debug exists before using it.
separateDebugInfo = true;
setupHook = ./setup-hook.sh;
meta = {
homepage = "https://root.cern/";
description = "Data analysis framework";
platforms = lib.platforms.unix;
maintainers = [
lib.maintainers.guitargeek
lib.maintainers.veprbl
];
license = lib.licenses.lgpl21;
};
})