diff --git a/pkgs/development/libraries/glfw/3.x.nix b/pkgs/development/libraries/glfw/3.x.nix index 37c15225869f..f9089384a8a5 100644 --- a/pkgs/development/libraries/glfw/3.x.nix +++ b/pkgs/development/libraries/glfw/3.x.nix @@ -1,6 +1,8 @@ { stdenv, lib, fetchFromGitHub, cmake , libGL, libXrandr, libXinerama, libXcursor, libX11, libXi, libXext , Cocoa, Kernel, fixDarwinDylibNames +, waylandSupport ? false, extra-cmake-modules, wayland +, wayland-protocols, libxkbcommon }: stdenv.mkDerivation rec { @@ -14,20 +16,34 @@ stdenv.mkDerivation rec { sha256 = "sha256-BP4wxjgm0x0E68tNz5eudkVUyBnXkQlP7LY3ppZunhw="; }; + patches = lib.optional waylandSupport ./wayland.patch; + propagatedBuildInputs = [ libGL ]; nativeBuildInputs = [ cmake ] - ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; + ++ lib.optional stdenv.isDarwin fixDarwinDylibNames + ++ lib.optional waylandSupport extra-cmake-modules; - buildInputs = [ libX11 libXrandr libXinerama libXcursor libXi libXext ] - ++ lib.optionals stdenv.isDarwin [ Cocoa Kernel ]; + buildInputs = + if waylandSupport + then [ wayland wayland-protocols libxkbcommon ] + else [ libX11 libXrandr libXinerama libXcursor libXi libXext ] + ++ lib.optionals stdenv.isDarwin [ Cocoa Kernel ]; cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" - ] ++ lib.optional (!stdenv.isDarwin) [ + ] ++ lib.optionals (!stdenv.isDarwin) [ "-DCMAKE_C_FLAGS=-D_GLFW_GLX_LIBRARY='\"${lib.getLib libGL}/lib/libGL.so.1\"'" + ] ++ lib.optionals waylandSupport [ + "-DGLFW_USE_WAYLAND=ON" + "-DCMAKE_C_FLAGS=-D_GLFW_EGL_LIBRARY='\"${lib.getLib libGL}/lib/libEGL.so.1\"'" ]; + postPatch = lib.optionalString waylandSupport '' + substituteInPlace src/wl_init.c \ + --replace "libxkbcommon.so.0" "${lib.getLib libxkbcommon}/lib/libxkbcommon.so.0" + ''; + meta = with lib; { description = "Multi-platform library for creating OpenGL contexts and managing input, including keyboard, mouse, joystick and time"; homepage = "https://www.glfw.org/"; diff --git a/pkgs/development/libraries/glfw/wayland.patch b/pkgs/development/libraries/glfw/wayland.patch new file mode 100644 index 000000000000..c0c338f845b3 --- /dev/null +++ b/pkgs/development/libraries/glfw/wayland.patch @@ -0,0 +1,25 @@ +From 46fb81c69e8acdb70907409f98dd01e387408414 Mon Sep 17 00:00:00 2001 +From: Stone Tickle +Date: Fri, 5 Jun 2020 12:51:25 +0900 +Subject: [PATCH] set O_NONBLOCK on repeat timerfd + +--- + src/wl_init.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/wl_init.c b/src/wl_init.c +index 49e7cc52..43569bef 100644 +--- a/src/wl_init.c ++++ b/src/wl_init.c +@@ -1166,7 +1166,7 @@ int _glfwPlatformInit(void) + + _glfw.wl.timerfd = -1; + if (_glfw.wl.seatVersion >= 4) +- _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); ++ _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK); + + if (_glfw.wl.pointer && _glfw.wl.shm) + { +-- +2.31.1 + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 912f223de63d..d5b934a84f07 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15310,6 +15310,9 @@ in }); glfw = glfw3; + glfw-wayland = glfw.override { + waylandSupport = true; + }; glfw2 = callPackage ../development/libraries/glfw/2.x.nix { }; glfw3 = callPackage ../development/libraries/glfw/3.x.nix { inherit (darwin.apple_sdk.frameworks) Cocoa Kernel;