about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/glfw
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-07-23 09:26:00 +0000
committerAlyssa Ross <hi@alyssa.is>2021-07-23 09:26:00 +0000
commitab63e0bb8dcf2b1bf8d4a26ed360af777b8f241d (patch)
tree504b28a058661f6c1cbb7d3f580020e50367ca7f /nixpkgs/pkgs/development/libraries/glfw
parent55cc63c079f49e81d695a25bc2f5b3902f2bd290 (diff)
parentb09661d41fb93562fd53f31574dbf781b130ac44 (diff)
downloadnixlib-ab63e0bb8dcf2b1bf8d4a26ed360af777b8f241d.tar
nixlib-ab63e0bb8dcf2b1bf8d4a26ed360af777b8f241d.tar.gz
nixlib-ab63e0bb8dcf2b1bf8d4a26ed360af777b8f241d.tar.bz2
nixlib-ab63e0bb8dcf2b1bf8d4a26ed360af777b8f241d.tar.lz
nixlib-ab63e0bb8dcf2b1bf8d4a26ed360af777b8f241d.tar.xz
nixlib-ab63e0bb8dcf2b1bf8d4a26ed360af777b8f241d.tar.zst
nixlib-ab63e0bb8dcf2b1bf8d4a26ed360af777b8f241d.zip
Merge commit 'b09661d41fb93562fd53f31574dbf781b130ac44'
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/glfw')
-rw-r--r--nixpkgs/pkgs/development/libraries/glfw/3.x.nix24
-rw-r--r--nixpkgs/pkgs/development/libraries/glfw/wayland.patch25
2 files changed, 45 insertions, 4 deletions
diff --git a/nixpkgs/pkgs/development/libraries/glfw/3.x.nix b/nixpkgs/pkgs/development/libraries/glfw/3.x.nix
index 37c15225869f..f9089384a8a5 100644
--- a/nixpkgs/pkgs/development/libraries/glfw/3.x.nix
+++ b/nixpkgs/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/nixpkgs/pkgs/development/libraries/glfw/wayland.patch b/nixpkgs/pkgs/development/libraries/glfw/wayland.patch
new file mode 100644
index 000000000000..c0c338f845b3
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/glfw/wayland.patch
@@ -0,0 +1,25 @@
+From 46fb81c69e8acdb70907409f98dd01e387408414 Mon Sep 17 00:00:00 2001
+From: Stone Tickle <lattis@mochiro.moe>
+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
+