nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 callPackage,
5 fetchFromGitHub,
6 fetchurl,
7 makeWrapper,
8 writeText,
9 apple-sdk,
10 cmake,
11 coreutils,
12 git,
13 davix,
14 fftw,
15 ftgl,
16 gl2ps,
17 glew,
18 gnugrep,
19 gnused,
20 gsl,
21 libGLU,
22 libGL,
23 libxcrypt,
24 libxml2,
25 llvm_20,
26 lsof,
27 lz4,
28 libxpm,
29 libxft,
30 libxext,
31 libx11,
32 xz,
33 man,
34 openssl,
35 pcre2,
36 nlohmann_json,
37 pkg-config,
38 procps,
39 python3,
40 which,
41 xxHash,
42 zlib,
43 zstd,
44 giflib,
45 libjpeg,
46 libtiff,
47 libpng,
48 patchRcPathCsh,
49 patchRcPathFish,
50 patchRcPathPosix,
51 onetbb,
52 xrootd,
53}:
54
55stdenv.mkDerivation (finalAttrs: {
56 pname = "root";
57 version = "6.38.00";
58
59 passthru = {
60 tests = import ./tests { inherit callPackage; };
61 };
62
63 src = fetchurl {
64 url = "https://root.cern.ch/download/root_v${finalAttrs.version}.source.tar.gz";
65 hash = "sha256-pEKUIsRg+DLN5RSlgN0gKx08luiRnCQ2PD1C+M9azNw=";
66 };
67
68 clad_src = fetchFromGitHub {
69 owner = "vgvassilev";
70 repo = "clad";
71 # Make sure that this is the same tag as in the ROOT build files!
72 # https://github.com/root-project/root/blob/master/interpreter/cling/tools/plugins/clad/CMakeLists.txt#L76
73 tag = "v2.0";
74 hash = "sha256-Oj7gGSvnGuYdggonPWjrwPn/06cD+ig3eefRh7xaiPs=";
75 };
76
77 # ROOT requires a patched version of clang
78 clang = (callPackage ./clang-root.nix { });
79
80 nativeBuildInputs = [
81 makeWrapper
82 cmake
83 pkg-config
84 git
85 ];
86 propagatedBuildInputs = [
87 nlohmann_json # link interface of target "ROOT::ROOTEve"
88 ];
89 buildInputs = [
90 finalAttrs.clang
91 davix
92 fftw
93 ftgl
94 giflib
95 gl2ps
96 glew
97 gsl
98 libjpeg
99 libpng
100 libtiff
101 libxcrypt
102 libxml2
103 llvm_20
104 lz4
105 openssl
106 patchRcPathCsh
107 patchRcPathFish
108 patchRcPathPosix
109 pcre2
110 python3
111 onetbb
112 xrootd
113 xxHash
114 xz
115 zlib
116 zstd
117 ]
118 ++ lib.optionals stdenv.hostPlatform.isDarwin [ apple-sdk.privateFrameworksHook ]
119 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
120 libGLU
121 libGL
122 libx11
123 libxpm
124 libxft
125 libxext
126 ];
127
128 preConfigure = ''
129 for path in builtins/*; do
130 if [[ "$path" != "builtins/openui5" ]] && [[ "$path" != "builtins/rendercore" ]]; then
131 rm -rf "$path"
132 fi
133 done
134 substituteInPlace cmake/modules/SearchInstalledSoftware.cmake \
135 --replace-fail 'set(lcgpackages ' '#set(lcgpackages '
136
137 patchShebangs cmake/unix/
138 ''
139 + lib.optionalString stdenv.hostPlatform.isDarwin ''
140 # Eliminate impure reference to /System/Library/PrivateFrameworks
141 substituteInPlace core/macosx/CMakeLists.txt \
142 --replace-fail "-F/System/Library/PrivateFrameworks " ""
143 ''
144 +
145 lib.optionalString
146 (stdenv.hostPlatform.isDarwin && lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11")
147 ''
148 MACOSX_DEPLOYMENT_TARGET=10.16
149 '';
150
151 cmakeFlags = [
152 "-DCLAD_SOURCE_DIR=${finalAttrs.clad_src}"
153 "-DClang_DIR=${finalAttrs.clang}/lib/cmake/clang"
154 "-Dbuiltin_clang=OFF"
155 "-Dbuiltin_llvm=OFF"
156 "-Dfail-on-missing=ON"
157 "-Dfftw3=ON"
158 "-Dfitsio=OFF"
159 "-Dmathmore=ON"
160 "-Dsqlite=OFF"
161 "-Dvdt=OFF"
162 ]
163 ++ lib.optionals stdenv.hostPlatform.isDarwin [
164 # fatal error: module map file '/nix/store/<hash>-Libsystem-osx-10.12.6/include/module.modulemap' not found
165 # fatal error: could not build module '_Builtin_intrinsics'
166 "-Druntime_cxxmodules=OFF"
167 ];
168
169 postInstall = ''
170 for prog in rootbrowse rootcp rooteventselector rootls rootmkdir rootmv rootprint rootrm rootslimtree; do
171 wrapProgram "$out/bin/$prog" \
172 --set PYTHONPATH "$out/lib"
173 done
174
175 # Make ldd and sed available to the ROOT executable by prefixing PATH.
176 wrapProgram "$out/bin/root" \
177 --prefix PATH : "${
178 lib.makeBinPath [
179 gnused # sed
180 stdenv.cc # c++ ld etc.
181 stdenv.cc.libc # ldd
182 ]
183 }"
184
185 # Patch thisroot.{sh,csh,fish}
186
187 # The main target of `thisroot.sh` is "bash-like shells",
188 # but it also need to support Bash-less POSIX shell like dash,
189 # as they are mentioned in `thisroot.sh`.
190
191 patchRcPathPosix "$out/bin/thisroot.sh" "${
192 lib.makeBinPath [
193 coreutils # dirname tail
194 gnugrep # grep
195 gnused # sed
196 lsof # lsof
197 man # manpath
198 procps # ps
199 which # which
200 ]
201 }"
202 patchRcPathCsh "$out/bin/thisroot.csh" "${
203 lib.makeBinPath [
204 coreutils
205 gnugrep
206 gnused
207 lsof # lsof
208 man
209 which
210 ]
211 }"
212 patchRcPathFish "$out/bin/thisroot.fish" "${
213 lib.makeBinPath [
214 coreutils
215 man
216 which
217 ]
218 }"
219 '';
220
221 # To use the debug information on the fly (without installation)
222 # add the outPath of root.debug into NIX_DEBUG_INFO_DIRS (in PATH-like format)
223 # and make sure that gdb from Nixpkgs can be found in PATH.
224 #
225 # Darwin currently fails to support it (#203380)
226 # we set it to true hoping to benefit from the future fix.
227 # Before that, please make sure if root.debug exists before using it.
228 separateDebugInfo = true;
229
230 setupHook = ./setup-hook.sh;
231
232 meta = {
233 homepage = "https://root.cern/";
234 description = "Data analysis framework";
235 platforms = lib.platforms.unix;
236 maintainers = [
237 lib.maintainers.guitargeek
238 lib.maintainers.veprbl
239 ];
240 license = lib.licenses.lgpl21;
241 };
242})