2019-10-07 13:29:31 +00:00
|
|
|
{ stdenv, lib, fetchFromGitHub, cmake
|
|
|
|
, libGL, libXrandr, libXinerama, libXcursor, libX11, libXi, libXext
|
2023-06-05 11:18:55 +00:00
|
|
|
, Carbon, Cocoa, Kernel, OpenGL, fixDarwinDylibNames
|
2021-07-14 10:45:21 +00:00
|
|
|
, waylandSupport ? false, extra-cmake-modules, wayland
|
|
|
|
, wayland-protocols, libxkbcommon
|
2015-05-25 02:49:54 +00:00
|
|
|
}:
|
2014-02-04 19:13:30 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2022-07-28 12:49:40 +00:00
|
|
|
version = "3.3.8";
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "glfw";
|
2014-02-04 19:13:30 +00:00
|
|
|
|
2015-10-12 22:16:27 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "glfw";
|
|
|
|
repo = "GLFW";
|
2019-09-08 23:38:31 +00:00
|
|
|
rev = version;
|
2022-07-28 12:49:40 +00:00
|
|
|
sha256 = "sha256-4+H0IXjAwbL5mAWfsIVhW0BSJhcWjkQx4j2TrzZ3aIo=";
|
2014-02-04 19:13:30 +00:00
|
|
|
};
|
|
|
|
|
2022-04-11 22:58:59 +00:00
|
|
|
# Fix linkage issues on X11 (https://github.com/NixOS/nixpkgs/issues/142583)
|
|
|
|
patches = lib.optional (!waylandSupport) ./x11.patch;
|
2021-07-14 10:45:21 +00:00
|
|
|
|
2023-06-05 11:18:55 +00:00
|
|
|
propagatedBuildInputs = [ (if stdenv.isDarwin then OpenGL else libGL) ];
|
2017-09-27 20:28:36 +00:00
|
|
|
|
2020-10-26 07:17:14 +00:00
|
|
|
nativeBuildInputs = [ cmake ]
|
2021-07-14 10:45:21 +00:00
|
|
|
++ lib.optional stdenv.isDarwin fixDarwinDylibNames
|
|
|
|
++ lib.optional waylandSupport extra-cmake-modules;
|
2017-09-27 20:28:36 +00:00
|
|
|
|
2021-07-14 10:45:21 +00:00
|
|
|
buildInputs =
|
|
|
|
if waylandSupport
|
|
|
|
then [ wayland wayland-protocols libxkbcommon ]
|
|
|
|
else [ libX11 libXrandr libXinerama libXcursor libXi libXext ]
|
2023-06-05 11:18:55 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ Carbon Cocoa Kernel ];
|
2015-05-25 02:49:54 +00:00
|
|
|
|
2021-02-02 13:24:19 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DBUILD_SHARED_LIBS=ON"
|
2021-07-14 10:45:21 +00:00
|
|
|
] ++ lib.optionals (!stdenv.isDarwin) [
|
2021-02-02 13:24:19 +00:00
|
|
|
"-DCMAKE_C_FLAGS=-D_GLFW_GLX_LIBRARY='\"${lib.getLib libGL}/lib/libGL.so.1\"'"
|
2021-07-14 10:45:21 +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-02 13:24:19 +00:00
|
|
|
];
|
2018-09-19 08:50:35 +00:00
|
|
|
|
2021-07-14 10:45:21 +00:00
|
|
|
postPatch = lib.optionalString waylandSupport ''
|
|
|
|
substituteInPlace src/wl_init.c \
|
|
|
|
--replace "libxkbcommon.so.0" "${lib.getLib libxkbcommon}/lib/libxkbcommon.so.0"
|
|
|
|
'';
|
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
meta = with lib; {
|
2014-02-04 19:13:30 +00:00
|
|
|
description = "Multi-platform library for creating OpenGL contexts and managing input, including keyboard, mouse, joystick and time";
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://www.glfw.org/";
|
2014-02-04 19:13:30 +00:00
|
|
|
license = licenses.zlib;
|
2019-10-07 13:29:31 +00:00
|
|
|
maintainers = with maintainers; [ marcweber twey ];
|
2017-04-29 01:34:43 +00:00
|
|
|
platforms = platforms.unix;
|
2014-02-04 19:13:30 +00:00
|
|
|
};
|
|
|
|
}
|