From c2039e1901aca58527d8c1a3206accac3b8482cb Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Fri, 29 May 2020 22:29:32 -0500 Subject: [PATCH] mesa: make more things optional (#87438) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit osmesa & gallium-nine are not needed for all systems. So this adds a flag to disable them if you don’t want them. --- pkgs/development/libraries/mesa/default.nix | 36 +++++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/pkgs/development/libraries/mesa/default.nix b/pkgs/development/libraries/mesa/default.nix index aa70e9e5a54..e46f3fb1488 100644 --- a/pkgs/development/libraries/mesa/default.nix +++ b/pkgs/development/libraries/mesa/default.nix @@ -11,6 +11,8 @@ , eglPlatforms ? [ "x11" "surfaceless" ] ++ lib.optionals stdenv.isLinux [ "wayland" "drm" ] , OpenGL, Xplugin , withValgrind ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAarch32, valgrind-light +, enableGalliumNine ? stdenv.isLinux +, enableOSMesa ? stdenv.isLinux }: /** Packaging design: @@ -79,7 +81,7 @@ stdenv.mkDerivation { "find_program('${buildPackages.pkg-config.targetPrefix}pkg-config')" ''; - outputs = [ "out" "dev" "drivers" "osmesa" ]; + outputs = [ "out" "dev" "drivers" ] ++ lib.optional enableOSMesa "osmesa"; # TODO: Figure out how to enable opencl without having a runtime dependency on clang mesonFlags = [ @@ -103,10 +105,10 @@ stdenv.mkDerivation { "-Domx-libs-path=${placeholder "drivers"}/lib/bellagio" "-Dva-libs-path=${placeholder "drivers"}/lib/dri" "-Dd3d-drivers-path=${placeholder "drivers"}/lib/d3d" + "-Dgallium-nine=${if enableGalliumNine then "true" else "false"}" # Direct3D in Wine + "-Dosmesa=${if enableOSMesa then "gallium" else "none"}" # used by wine ] ++ optionals stdenv.isLinux [ "-Dglvnd=true" - "-Dosmesa=gallium" # used by wine - "-Dgallium-nine=true" # Direct3D in Wine ]; buildInputs = with xorg; [ @@ -142,17 +144,17 @@ stdenv.mkDerivation { '' + optionalString stdenv.isLinux '' mkdir -p $drivers/lib - # move gallium-related stuff to $drivers, so $out doesn't depend on LLVM - mv -t $drivers/lib \ - $out/lib/libxatracker* \ - $out/lib/libvulkan_* + if [ -n "$(shopt -s nullglob; echo "$out/lib/libxatracker"*)" -o -n "$(shopt -s nullglob; echo "$out/lib/libvulkan_"*)" ]; then + # move gallium-related stuff to $drivers, so $out doesn't depend on LLVM + mv -t $drivers/lib \ + $out/lib/libxatracker* \ + $out/lib/libvulkan_* + fi - # Move other drivers to a separate output - mv $out/lib/lib*_mesa* $drivers/lib - - # move libOSMesa to $osmesa, as it's relatively big - mkdir -p $osmesa/lib - mv -t $osmesa/lib/ $out/lib/libOSMesa* + if [ -n "$(shopt -s nullglob; echo "$out"/lib/lib*_mesa*)" ]; then + # Move other drivers to a separate output + mv $out/lib/lib*_mesa* $drivers/lib + fi # move vendor files mv $out/share/ $drivers/ @@ -167,6 +169,10 @@ stdenv.mkDerivation { for js in $drivers/share/vulkan/icd.d/*.json; do substituteInPlace "$js" --replace "$out" "$drivers" done + '' + lib.optionalString enableOSMesa '' + # move libOSMesa to $osmesa, as it's relatively big + mkdir -p $osmesa/lib + mv -t $osmesa/lib/ $out/lib/libOSMesa* ''; # TODO: @@ -181,7 +187,9 @@ stdenv.mkDerivation { # Update search path used by pkg-config for pc in $dev/lib/pkgconfig/{d3d,dri,xatracker}.pc; do - substituteInPlace "$pc" --replace $out $drivers + if [ -f "$pc" ]; then + substituteInPlace "$pc" --replace $out $drivers + fi done # add RPATH so the drivers can find the moved libgallium and libdricore9