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