From d309a2a0456d079ca29368145e5f24d524cf7f3d Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Tue, 5 May 2026 02:20:10 +0200 Subject: [PATCH] librealsense: add enableExamples flag, default it to false Somewhere in the cmake machinery is a missing include/find for OpenGL::GL when BUILD_EXAMPLES=ON and BUILD_GRAPHICAL_EXAMPLES=OFF This fixes build for all other variants than librealsense-gui. --- pkgs/development/libraries/librealsense/default.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/librealsense/default.nix b/pkgs/development/libraries/librealsense/default.nix index da82e87e9610..815a6b8b2d8f 100644 --- a/pkgs/development/libraries/librealsense/default.nix +++ b/pkgs/development/libraries/librealsense/default.nix @@ -24,11 +24,13 @@ cudaPackages ? { }, enablePython ? false, pythonPackages ? null, + enableExamples ? enableGUI, # currently broken without enableGUI enableGUI ? false, }: assert cudaSupport -> (cudaPackages ? cudatoolkit && cudaPackages.cudatoolkit != null); assert enablePython -> pythonPackages != null; +assert enableGUI -> enableExamples; let stdenv' = if cudaSupport then cudaPackages.backendStdenv else stdenv; @@ -63,10 +65,12 @@ stdenv'.mkDerivation rec { pybind11 ] ) + ++ lib.optionals (enableExamples || enableGUI) [ + glfw + ] ++ lib.optionals enableGUI [ libgbm gtk3 - glfw libGLU curl ]; @@ -95,7 +99,7 @@ stdenv'.mkDerivation rec { ]; cmakeFlags = [ - "-DBUILD_EXAMPLES=ON" + "-DBUILD_EXAMPLES=${lib.boolToString enableExamples}" "-DBUILD_GRAPHICAL_EXAMPLES=${lib.boolToString enableGUI}" "-DBUILD_GLSL_EXTENSIONS=${lib.boolToString enableGUI}" "-DCHECK_FOR_UPDATES=OFF" # activated by BUILD_GRAPHICAL_EXAMPLES, will make it download and compile libcurl @@ -185,5 +189,6 @@ stdenv'.mkDerivation rec { pbsds ]; platforms = lib.platforms.unix; + mainProgram = if enableGUI then "realsense-viewer" else "rs-enumerate-devices"; }; }