nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 backendStdenv,
3 buildRedist,
4 cudaAtLeast,
5 cudaMajorMinorVersion,
6 cudaOlder,
7 e2fsprogs,
8 elfutils,
9 flags,
10 gst_all_1,
11 lib,
12 libjpeg8,
13 qt5 ? null,
14 qt6 ? null,
15 rdma-core,
16 ucx,
17}:
18let
19 archDir =
20 {
21 aarch64-linux = "linux-" + (if flags.isJetsonBuild then "v4l_l4t" else "desktop") + "-t210-a64";
22 x86_64-linux = "linux-desktop-glibc_2_11_3-x64";
23 }
24 .${backendStdenv.hostPlatform.system}
25 or (throw "Unsupported system: ${backendStdenv.hostPlatform.system}");
26in
27buildRedist (
28 finalAttrs:
29 let
30 qt = if lib.versionOlder finalAttrs.version "2022.2.0" then qt5 else qt6;
31 qtwayland =
32 if lib.versions.major qt.qtbase.version == "5" then
33 lib.getBin qt.qtwayland
34 else
35 lib.getLib qt.qtwayland;
36 inherit (qt) wrapQtAppsHook qtwebengine qtwebview;
37 in
38 {
39 redistName = "cuda";
40 pname = "nsight_compute";
41
42 # NOTE(@connorbaker): It might be a problem that when nsight_compute contains hosts and targets of different
43 # architectures, that we patchelf just the binaries matching the builder's platform; autoPatchelfHook prints
44 # messages like
45 # skipping [$out]/host/linux-desktop-glibc_2_11_3-x64/libQt6Core.so.6 because its architecture (x64) differs from
46 # target (AArch64)
47 outputs = [ "out" ];
48
49 allowFHSReferences = true;
50
51 nativeBuildInputs = [ wrapQtAppsHook ];
52
53 buildInputs = [
54 (lib.getLib qtwayland)
55 qtwebengine
56 qtwebview
57 rdma-core
58 ]
59 ++ lib.optionals (cudaMajorMinorVersion == "12.0" && backendStdenv.hostPlatform.isAarch64) [
60 libjpeg8
61 ]
62 ++ lib.optionals (cudaAtLeast "12.1" && cudaOlder "12.4") [
63 gst_all_1.gstreamer
64 gst_all_1.gst-plugins-base
65 ]
66 ++ lib.optionals (cudaAtLeast "12.0" && cudaOlder "12.7") [
67 e2fsprogs
68 ucx
69 ]
70 ++ lib.optionals (cudaAtLeast "12.9") [ elfutils ];
71
72 dontWrapQtApps = true;
73
74 preInstall = ''
75 if [[ -d nsight-compute ]]; then
76 nixLog "Lifting components of Nsight Compute to the top level"
77 mv -v nsight-compute/*/* .
78 nixLog "Removing empty directories"
79 rmdir -pv nsight-compute/*
80 fi
81
82 rm -rf host/${archDir}/Mesa/
83
84 patchShebangs .
85 '';
86
87 postInstall = ''
88 moveToOutput 'ncu' "''${!outputBin}/bin"
89 moveToOutput 'ncu-ui' "''${!outputBin}/bin"
90 moveToOutput 'host/${archDir}' "''${!outputBin}/bin"
91 moveToOutput 'target/${archDir}' "''${!outputBin}/bin"
92 wrapQtApp "''${!outputBin}/bin/host/${archDir}/ncu-ui.bin"
93 ''
94 # NOTE(@connorbaker): No idea what this platform is or how to patchelf for it.
95 + lib.optionalString (flags.isJetsonBuild && cudaAtLeast "11.8" && cudaOlder "12.9") ''
96 nixLog "Removing QNX 700 target directory for Jetson builds"
97 rm -rfv "''${!outputBin}/target/qnx-700-t210-a64"
98 ''
99 + lib.optionalString (flags.isJetsonBuild && cudaAtLeast "12.8") ''
100 nixLog "Removing QNX 800 target directory for Jetson builds"
101 rm -rfv "''${!outputBin}/target/qnx-800-tegra-a64"
102 '';
103
104 # lib needs libtiff.so.5, but nixpkgs provides libtiff.so.6
105 preFixup = ''
106 patchelf --replace-needed libtiff.so.5 libtiff.so "''${!outputBin}/bin/host/${archDir}/Plugins/imageformats/libqtiff.so"
107 '';
108
109 autoPatchelfIgnoreMissingDeps = [
110 "libcuda.so.1"
111 "libnvidia-ml.so.1"
112 ];
113
114 brokenAssertions = [
115 {
116 message = "Qt 5 is required and available";
117 assertion = lib.versionOlder finalAttrs.version "2022.2.0" -> qt5 != null;
118 }
119 {
120 message = "Qt 6 is required and available";
121 assertion = lib.versionAtLeast finalAttrs.version "2022.2.0" -> qt6 != null;
122 }
123 ];
124
125 meta = {
126 description = "Interactive profiler for CUDA and NVIDIA OptiX";
127 longDescription = ''
128 NVIDIA Nsight Compute is an interactive profiler for CUDA and NVIDIA OptiX that provides detailed performance
129 metrics and API debugging via a user interface and command-line tool. Users can run guided analysis and compare
130 results with a customizable and data-driven user interface, as well as post-process and analyze results in their
131 own workflows.
132 '';
133 homepage = "https://developer.nvidia.com/nsight-compute";
134 changelog = "https://docs.nvidia.com/nsight-compute/ReleaseNotes";
135
136 mainProgram = "ncu";
137 };
138 }
139)