2020-04-24 23:36:52 +00:00
|
|
|
{ stdenv, lib, fetchFromGitHub, cmake
|
|
|
|
, libGL, libXrandr, libXinerama, libXcursor, libX11, libXi, libXext
|
|
|
|
, Cocoa, Kernel, fixDarwinDylibNames
|
2021-07-14 22:03:04 +00:00
|
|
|
, waylandSupport ? false, extra-cmake-modules, wayland
|
|
|
|
, wayland-protocols, libxkbcommon
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2021-12-06 16:07:01 +00:00
|
|
|
version = "3.3.5";
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "glfw";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "glfw";
|
|
|
|
repo = "GLFW";
|
|
|
|
rev = version;
|
2021-12-06 16:07:01 +00:00
|
|
|
sha256 = "sha256-1KkzYclOLGqiV1/8BsJ3e+pXMQ6a+sjLwZ7mjSuxxbA=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
# Fix freezing on Wayland (https://github.com/glfw/glfw/pull/1711)
|
|
|
|
# and linkage issues on X11 (https://github.com/NixOS/nixpkgs/issues/142583)
|
|
|
|
patches = if waylandSupport then ./wayland.patch else ./x11.patch;
|
2021-07-14 22:03:04 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
propagatedBuildInputs = [ libGL ];
|
|
|
|
|
2020-11-12 09:05:59 +00:00
|
|
|
nativeBuildInputs = [ cmake ]
|
2021-07-14 22:03:04 +00:00
|
|
|
++ lib.optional stdenv.isDarwin fixDarwinDylibNames
|
|
|
|
++ lib.optional waylandSupport extra-cmake-modules;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-07-14 22:03:04 +00:00
|
|
|
buildInputs =
|
|
|
|
if waylandSupport
|
|
|
|
then [ wayland wayland-protocols libxkbcommon ]
|
|
|
|
else [ libX11 libXrandr libXinerama libXcursor libXi libXext ]
|
|
|
|
++ lib.optionals stdenv.isDarwin [ Cocoa Kernel ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DBUILD_SHARED_LIBS=ON"
|
2021-07-14 22:03:04 +00:00
|
|
|
] ++ lib.optionals (!stdenv.isDarwin) [
|
2021-02-05 17:12:51 +00:00
|
|
|
"-DCMAKE_C_FLAGS=-D_GLFW_GLX_LIBRARY='\"${lib.getLib libGL}/lib/libGL.so.1\"'"
|
2021-07-14 22:03:04 +00:00
|
|
|
] ++ lib.optionals waylandSupport [
|
|
|
|
"-DGLFW_USE_WAYLAND=ON"
|
|
|
|
"-DCMAKE_C_FLAGS=-D_GLFW_EGL_LIBRARY='\"${lib.getLib libGL}/lib/libEGL.so.1\"'"
|
2021-02-05 17:12:51 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-07-14 22:03:04 +00:00
|
|
|
postPatch = lib.optionalString waylandSupport ''
|
|
|
|
substituteInPlace src/wl_init.c \
|
|
|
|
--replace "libxkbcommon.so.0" "${lib.getLib libxkbcommon}/lib/libxkbcommon.so.0"
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Multi-platform library for creating OpenGL contexts and managing input, including keyboard, mouse, joystick and time";
|
|
|
|
homepage = "https://www.glfw.org/";
|
|
|
|
license = licenses.zlib;
|
|
|
|
maintainers = with maintainers; [ marcweber twey ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|