From 14636cb1163df50e6e366743eca092df18b1ebff Mon Sep 17 00:00:00 2001 From: Connor Baker Date: Mon, 4 Aug 2025 10:55:17 -0700 Subject: [PATCH] cudaPackages.nsight_systems: fixup for SBSA aarch64-linux and x86_64-linux Signed-off-by: Connor Baker (cherry picked from commit b21e0a58d3f628e0ee446b2887fced278071e5f9) --- .../_cuda/fixups/nsight_systems.nix | 128 +++++++++++------- 1 file changed, 78 insertions(+), 50 deletions(-) diff --git a/pkgs/development/cuda-modules/_cuda/fixups/nsight_systems.nix b/pkgs/development/cuda-modules/_cuda/fixups/nsight_systems.nix index 9040dc36a21d..7ace96366b5f 100644 --- a/pkgs/development/cuda-modules/_cuda/fixups/nsight_systems.nix +++ b/pkgs/development/cuda-modules/_cuda/fixups/nsight_systems.nix @@ -1,6 +1,7 @@ { boost178, cuda_cudart, + cudaAtLeast, cudaOlder, e2fsprogs, gst_all_1, @@ -27,6 +28,7 @@ let else lib.getLib qt.qtwayland; qtWaylandPlugins = "${qtwayland}/${qt.qtbase.qtPluginPrefix}"; + # NOTE(@connorbaker): nsight_systems doesn't support Jetson, so no need for case splitting on aarch64-linux. hostDir = { aarch64-linux = "host-linux-armv8"; @@ -39,76 +41,102 @@ let x86_64-linux = "target-linux-x64"; } .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); - versionString = with lib.versions; "${majorMinor version}.${patch version}"; in { + outputs = [ "out" ]; # NOTE(@connorbaker): Force a single output so relative lookups work. + # An ad hoc replacement for # https://github.com/ConnorBaker/cuda-redist-find-features/issues/11 env = prevAttrs.env or { } // { rmPatterns = prevAttrs.env.rmPatterns or "" + toString [ - "nsight-systems/${versionString}/${hostDir}/lib{arrow,jpeg}*" - "nsight-systems/${versionString}/${hostDir}/lib{ssl,ssh,crypto}*" - "nsight-systems/${versionString}/${hostDir}/libboost*" - "nsight-systems/${versionString}/${hostDir}/libexec" - "nsight-systems/${versionString}/${hostDir}/libstdc*" - "nsight-systems/${versionString}/${hostDir}/python/bin/python" - "nsight-systems/${versionString}/${hostDir}/Mesa" + "${hostDir}/lib{arrow,jpeg}*" + "${hostDir}/lib{ssl,ssh,crypto}*" + "${hostDir}/libboost*" + "${hostDir}/libexec" + "${hostDir}/libstdc*" + "${hostDir}/python/bin/python" + "${hostDir}/Mesa" ]; }; + + # NOTE(@connorbaker): nsight-exporter and nsight-sys are deprecated scripts wrapping nsys, it's fine to remove them. + prePatch = prevAttrs.prePatch or "" + '' + if [[ -d bin ]]; then + nixLog "Removing bin wrapper scripts" + for knownWrapper in bin/{nsys{,-ui},nsight-{exporter,sys}}; do + [[ -e $knownWrapper ]] && rm -v "$knownWrapper" + done + unset -v knownWrapper + + nixLog "Removing empty bin directory" + rmdir -v bin + fi + + if [[ -d nsight-systems ]]; then + nixLog "Lifting components of Nsight System to the top level" + mv -v nsight-systems/*/* . + nixLog "Removing empty nsight-systems directory" + rmdir -pv nsight-systems/* + fi + ''; + postPatch = prevAttrs.postPatch or "" + '' for path in $rmPatterns; do rm -r "$path" done patchShebangs nsight-systems ''; - nativeBuildInputs = prevAttrs.nativeBuildInputs or [ ] ++ [ qt.wrapQtAppsHook ]; + + nativeBuildInputs = prevAttrs.nativeBuildInputs or [ ] ++ [ qt6.wrapQtAppsHook ]; + dontWrapQtApps = true; - buildInputs = prevAttrs.buildInputs or [ ] ++ [ - (qt.qtdeclarative or qt.full) - (qt.qtsvg or qt.full) - (qt.qtimageformats or qt.full) - (qt.qtpositioning or qt.full) - (qt.qtscxml or qt.full) - (qt.qttools or qt.full) - (qt.qtwebengine or qt.full) - (qt.qtwayland or qt.full) - boost178 - cuda_cudart.stubs - e2fsprogs - gst_all_1.gst-plugins-base - gst_all_1.gstreamer - nss - numactl - pulseaudio - qt.qtbase - qtWaylandPlugins - rdma-core - ucx - wayland - xorg.libXcursor - xorg.libXdamage - xorg.libXrandr - xorg.libXtst - ]; - postInstall = - prevAttrs.postInstall or "" - # 1. Move dependencies of nsys, nsys-ui binaries to bin output - # 2. Fix paths in wrapper scripts - + '' - moveToOutput 'nsight-systems/${versionString}/${hostDir}' "''${!outputBin}" - moveToOutput 'nsight-systems/${versionString}/${targetDir}' "''${!outputBin}" - moveToOutput 'nsight-systems/${versionString}/bin' "''${!outputBin}" - substituteInPlace $bin/bin/nsys $bin/bin/nsys-ui \ - --replace-fail 'nsight-systems-#VERSION_RSPLIT#' nsight-systems/${versionString} - wrapQtApp "$bin/nsight-systems/${versionString}/${hostDir}/nsys-ui.bin" - ''; + buildInputs = + prevAttrs.buildInputs or [ ] + ++ [ + (qt6.qtdeclarative or qt6.full) + (qt6.qtsvg or qt6.full) + (qt6.qtimageformats or qt6.full) + (qt6.qtpositioning or qt6.full) + (qt6.qtscxml or qt6.full) + (qt6.qttools or qt6.full) + (qt6.qtwebengine or qt6.full) + (qt6.qtwayland or qt6.full) + boost178 + cuda_cudart.stubs + e2fsprogs + gst_all_1.gst-plugins-base + gst_all_1.gstreamer + nss + numactl + pulseaudio + qt6.qtbase + qtWaylandPlugins + rdma-core + ucx + wayland + xorg.libXcursor + xorg.libXdamage + xorg.libXrandr + xorg.libXtst + ] + # NOTE(@connorbaker): Seems to be required only for aarch64-linux. + ++ lib.optionals (stdenv.hostPlatform.isAarch64 && cudaAtLeast "11.8") [ + gst_all_1.gst-plugins-bad + ]; + postInstall = prevAttrs.postInstall or "" + '' + moveToOutput '${hostDir}' "''${!outputBin}" + moveToOutput '${targetDir}' "''${!outputBin}" + moveToOutput 'bin' "''${!outputBin}" + wrapQtApp "''${!outputBin}/${hostDir}/nsys-ui.bin" + ''; + + # lib needs libtiff.so.5, but nixpkgs provides libtiff.so.6 preFixup = prevAttrs.preFixup or "" + '' - # lib needs libtiff.so.5, but nixpkgs provides libtiff.so.6 - patchelf --replace-needed libtiff.so.5 libtiff.so $bin/nsight-systems/${versionString}/${hostDir}/Plugins/imageformats/libqtiff.so + patchelf --replace-needed libtiff.so.5 libtiff.so "''${!outputBin}/${hostDir}/Plugins/imageformats/libqtiff.so" ''; autoPatchelfIgnoreMissingDeps = prevAttrs.autoPatchelfIgnoreMissingDeps or [ ] ++ [