Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[staging] addHardwareRunpath: init, alias addOpenGLRunpath #196174

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nixos/modules/services/x11/xserver.nix
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ in

environment =
optionalAttrs config.hardware.opengl.setLdLibraryPath
{ LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.addOpenGLRunpath.driverLink ]; }
{ LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.addHardwareRunpath.driverLink ]; }
// cfg.displayManager.job.environment;

preStart =
Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/graphics/renderdoc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
, pcre
, automake
, autoconf
, addOpenGLRunpath
, addHardwareRunpath
, waylandSupport ? false
, wayland
}:
Expand Down Expand Up @@ -47,7 +47,7 @@ mkDerivation rec {
# TODO: figure out how to make cmake recognise pyside2
++ lib.optional waylandSupport wayland;

nativeBuildInputs = [ cmake makeWrapper pkg-config bison pcre automake autoconf addOpenGLRunpath ];
nativeBuildInputs = [ cmake makeWrapper pkg-config bison pcre automake autoconf addHardwareRunpath ];

postUnpack = ''
cp -r ${custom_swig} swig
Expand Down Expand Up @@ -78,7 +78,7 @@ mkDerivation rec {

# The only documentation for this so far is in pkgs/build-support/add-opengl-runpath/setup-hook.sh
postFixup = ''
addOpenGLRunpath $out/lib/librenderdoc.so
addHardwareRunpath $out/lib/librenderdoc.so
'';

passthru.updateScript = nix-update-script {
Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/misc/blender/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
, libjpeg, libpng, libsamplerate, libsndfile
, libtiff, libGLU, libGL, openal, opencolorio, openexr, openimagedenoise, openimageio2, openjpeg, python310Packages
, openvdb, libXxf86vm, tbb, alembic
, zlib, zstd, fftw, opensubdiv, freetype, jemalloc, ocl-icd, addOpenGLRunpath
, zlib, zstd, fftw, opensubdiv, freetype, jemalloc, ocl-icd, addHardwareRunpath
, jackaudioSupport ? false, libjack2
, cudaSupport ? config.cudaSupport or false, cudaPackages ? {}
, hipSupport ? false, hip # comes with a significantly larger closure size
Expand Down Expand Up @@ -38,7 +38,7 @@ stdenv.mkDerivation rec {
patches = lib.optional stdenv.isDarwin ./darwin.patch;

nativeBuildInputs = [ cmake makeWrapper python310Packages.wrapPython llvmPackages.llvm.dev ]
++ optionals cudaSupport [ addOpenGLRunpath ];
++ optionals cudaSupport [ addHardwareRunpath ];
buildInputs =
[ boost ffmpeg gettext glew ilmbase
freetype libjpeg libpng libsamplerate libsndfile libtiff
Expand Down Expand Up @@ -157,7 +157,7 @@ stdenv.mkDerivation rec {
postFixup = optionalString cudaSupport ''
for program in $out/bin/blender $out/bin/.blender-wrapped; do
isELF "$program" || continue
addOpenGLRunpath "$program"
addHardwareRunpath "$program"
done
'';

Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/misc/firestarter/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
, lib
, fetchFromGitHub
, fetchzip
, addOpenGLRunpath
, addHardwareRunpath
, cmake
, glibc_multi
, glibc
Expand Down Expand Up @@ -67,7 +67,7 @@ stdenv.mkDerivation rec {
git
pkg-config
] ++ lib.optionals withCuda [
addOpenGLRunpath
addHardwareRunpath
];

buildInputs = [ hwloc ] ++ (if withCuda then
Expand Down Expand Up @@ -95,7 +95,7 @@ stdenv.mkDerivation rec {
'';

postFixup = lib.optionalString withCuda ''
addOpenGLRunpath $out/bin/FIRESTARTER_CUDA
addHardwareRunpath $out/bin/FIRESTARTER_CUDA
'';

meta = with lib; {
Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/misc/gpu-burn/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, stdenv, fetchFromGitHub, addOpenGLRunpath, cudatoolkit }:
{ lib, stdenv, fetchFromGitHub, addHardwareRunpath, cudatoolkit }:

stdenv.mkDerivation rec {
pname = "gpu-burn";
Expand All @@ -19,7 +19,7 @@ stdenv.mkDerivation rec {

buildInputs = [ cudatoolkit ];

nativeBuildInputs = [ addOpenGLRunpath ];
nativeBuildInputs = [ addHardwareRunpath ];

makeFlags = [ "CUDAPATH=${cudatoolkit}" ];

Expand All @@ -32,7 +32,7 @@ stdenv.mkDerivation rec {
'';

postFixup = ''
addOpenGLRunpath $out/bin/gpu_burn
addHardwareRunpath $out/bin/gpu_burn
'';

meta = with lib; {
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/networking/browsers/brave/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

# For Vulkan support (--enable-features=Vulkan); disabled by default as it seems to break VA-API
, vulkanSupport ? false
, addOpenGLRunpath
, addHardwareRunpath
, enableVulkan ? vulkanSupport
}:

Expand Down Expand Up @@ -179,7 +179,7 @@ stdenv.mkDerivation rec {
''}
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
${optionalString vulkanSupport ''
--prefix XDG_DATA_DIRS : "${addOpenGLRunpath.driverLink}/share"
--prefix XDG_DATA_DIRS : "${addHardwareRunpath.driverLink}/share"
--add-flags ${escapeShellArg commandLineArgs}
''}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
, libvaSupport ? true, libva

# For Vulkan support (--enable-features=Vulkan)
, addOpenGLRunpath
, addHardwareRunpath
}:

with lib;
Expand Down Expand Up @@ -146,7 +146,7 @@ in stdenv.mkDerivation {
--prefix LD_LIBRARY_PATH : "$rpath" \
--prefix PATH : "$binpath" \
--suffix PATH : "${lib.makeBinPath [ xdg-utils ]}" \
--prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH:${addOpenGLRunpath.driverLink}/share" \
--prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH:${addHardwareRunpath.driverLink}/share" \
--set CHROME_WRAPPER "google-chrome-$dist" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
--add-flags ${escapeShellArg commandLineArgs}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ addOpenGLRunpath
{ addHardwareRunpath
, alsa-lib
, at-spi2-atk
, at-spi2-core
Expand Down Expand Up @@ -159,7 +159,7 @@ stdenv.mkDerivation rec {
for executable in $out/opt/bytedance/feishu/{feishu,vulcan/vulcan}; do
wrapProgram $executable \
--prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH" \
--prefix LD_LIBRARY_PATH : ${rpath}:$out/opt/bytedance/feishu:${addOpenGLRunpath.driverLink}/share \
--prefix LD_LIBRARY_PATH : ${rpath}:$out/opt/bytedance/feishu:${addHardwareRunpath.driverLink}/share \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
${lib.optionalString (commandLineArgs!="") "--add-flags ${lib.escapeShellArg commandLineArgs}"}
done
Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/science/math/cntk/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
, fetchpatch
, openblas, blas, lapack, opencv3, libzip, boost, protobuf, mpi
, onebitSGDSupport ? false
, cudaSupport ? false, cudaPackages ? {}, addOpenGLRunpath, cudatoolkit, nvidia_x11
, cudaSupport ? false, cudaPackages ? {}, addHardwareRunpath, cudatoolkit, nvidia_x11
, cudnnSupport ? cudaSupport
}:

Expand Down Expand Up @@ -54,7 +54,7 @@ in stdenv.mkDerivation rec {
'SetTotalBytesLimit(limit)'
'';

nativeBuildInputs = [ cmake ] ++ lib.optional cudaSupport addOpenGLRunpath;
nativeBuildInputs = [ cmake ] ++ lib.optional cudaSupport addHardwareRunpath;

# Force OpenMPI to use g++ in PATH.
OMPI_CXX = "g++";
Expand Down Expand Up @@ -115,7 +115,7 @@ in stdenv.mkDerivation rec {

postFixup = lib.optionalString cudaSupport ''
for lib in $out/lib/*; do
addOpenGLRunpath "$lib"
addHardwareRunpath "$lib"
done
'';

Expand Down
10 changes: 5 additions & 5 deletions pkgs/applications/science/math/mathematica/generic.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ addOpenGLRunpath
{ addHardwareRunpath
, autoPatchelfHook
, lib
, makeWrapper
Expand Down Expand Up @@ -56,7 +56,7 @@ let cudaEnv = symlinkJoin {
cuda_cudart cuda_nvcc libcublas libcufft libcurand libcusparse
];
postBuild = ''
ln -s ${addOpenGLRunpath.driverLink}/lib/libcuda.so $out/lib
ln -s ${addHardwareRunpath.driverLink}/lib/libcuda.so $out/lib
ln -s lib $out/lib64
'';
};
Expand All @@ -67,7 +67,7 @@ in stdenv.mkDerivation {
nativeBuildInputs = [
autoPatchelfHook
makeWrapper
] ++ lib.optional cudaSupport addOpenGLRunpath;
] ++ lib.optional cudaSupport addHardwareRunpath;

buildInputs = [
alsa-lib
Expand Down Expand Up @@ -129,8 +129,8 @@ in stdenv.mkDerivation {
"--set QT_QPA_PLATFORM xcb"
] ++ lib.optionals cudaSupport [
"--set CUDA_PATH ${cudaEnv}"
"--set NVIDIA_DRIVER_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib/libnvidia-tls.so"
"--set CUDA_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib/libcuda.so"
"--set NVIDIA_DRIVER_LIBRARY_PATH ${addHardwareRunpath.driverLink}/lib/libnvidia-tls.so"
"--set CUDA_LIBRARY_PATH ${addHardwareRunpath.driverLink}/lib/libcuda.so"
];

unpackPhase = ''
Expand Down
8 changes: 4 additions & 4 deletions pkgs/applications/video/davinci-resolve/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
, targetPlatform
, unzip
, appimage-run
, addOpenGLRunpath
, addHardwareRunpath
, libGLU
, xorg
, buildFHSUserEnv
Expand All @@ -25,7 +25,7 @@ let
pname = "davinci-resolve";
version = "17.4.3";

nativeBuildInputs = [ unzip appimage-run addOpenGLRunpath ];
nativeBuildInputs = [ unzip appimage-run addHardwareRunpath ];

# Pretty sure, there are missing dependencies ...
buildInputs = [ libGLU xorg.libXxf86vm ];
Expand Down Expand Up @@ -117,14 +117,14 @@ let
postFixup = ''
for program in $out/bin/*; do
isELF "$program" || continue
addOpenGLRunpath "$program"
addHardwareRunpath "$program"
done

for program in $out/libs/*; do
isELF "$program" || continue
if [[ "$program" != *"libcudnn_cnn_infer"* ]];then
echo $program
addOpenGLRunpath "$program"
addHardwareRunpath "$program"
fi
done
'';
Expand Down
8 changes: 4 additions & 4 deletions pkgs/applications/video/mpv/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
, lib
, stdenv
, fetchFromGitHub
, addOpenGLRunpath
, addHardwareRunpath
, docutils
, perl
, pkg-config
Expand Down Expand Up @@ -124,7 +124,7 @@ in stdenv.mkDerivation rec {
++ lib.optional (!swiftSupport) "--disable-macos-cocoa-cb";

nativeBuildInputs = [
addOpenGLRunpath
addHardwareRunpath
docutils
perl
pkg-config
Expand Down Expand Up @@ -198,9 +198,9 @@ in stdenv.mkDerivation rec {
'';

# Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found.
# See the explanation in addOpenGLRunpath.
# See the explanation in addHardwareRunpath.
postFixup = lib.optionalString stdenv.isLinux ''
addOpenGLRunpath $out/bin/mpv
addHardwareRunpath $out/bin/mpv
'';

passthru = {
Expand Down
8 changes: 4 additions & 4 deletions pkgs/applications/video/obs-studio/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
, stdenv
, mkDerivation
, fetchFromGitHub
, addOpenGLRunpath
, addHardwareRunpath
, cmake
, fdk_aac
, ffmpeg_4
Expand Down Expand Up @@ -62,7 +62,7 @@ mkDerivation rec {
];

nativeBuildInputs = [
addOpenGLRunpath
addHardwareRunpath
cmake
pkg-config
wrapGAppsHook
Expand Down Expand Up @@ -128,8 +128,8 @@ mkDerivation rec {
'';

postFixup = lib.optionalString stdenv.isLinux ''
addOpenGLRunpath $out/lib/lib*.so
addOpenGLRunpath $out/lib/obs-plugins/*.so
addHardwareRunpath $out/lib/lib*.so
addHardwareRunpath $out/lib/obs-plugins/*.so
'';

meta = with lib; {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ stdenv
, lib
, addOpenGLRunpath
, addHardwareRunpath
, fetchFromGitHub
, pkg-config
, libelf
Expand Down Expand Up @@ -101,7 +101,7 @@ stdenv.mkDerivation rec {

postInstall =
let
inherit (addOpenGLRunpath) driverLink;
inherit (addHardwareRunpath) driverLink;
libraryPath = lib.makeLibraryPath [ "$out" driverLink "${driverLink}-32" ];
in
''
Expand Down
4 changes: 2 additions & 2 deletions pkgs/build-support/add-opengl-runpath/setup-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
# actually sets RUNPATH not RPATH, which applies only to dependencies of the binary
# it set on (including for dlopen), so the RUNPATH must indeed be set on these
# libraries and would not work if set only on executables.
addOpenGLRunpath() {
addHardwareRunpath() {
local forceRpath=

while [ $# -gt 0 ]; do
case "$1" in
--) shift; break;;
--force-rpath) shift; forceRpath=1;;
--*)
echo "addOpenGLRunpath: ERROR: Invalid command line" \
echo "addHardwareRunpath: ERROR: Invalid command line" \
"argument: $1" >&2
return 1;;
*) break;;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ echo "Sourcing auto-add-opengl-runpath-hook"
autoAddOpenGLRunpathPhase () {
# TODO: support multiple outputs
for file in $(find ${out,lib,bin} -type f); do
addOpenGLRunpath $file
addHardwareRunpath $file
done
}

Expand Down
Loading