2020-04-24 23:36:52 +00:00
|
|
|
{ stdenv, lib, fetchFromGitHub, cmake
|
|
|
|
, libGL, libXrandr, libXinerama, libXcursor, libX11, libXi, libXext
|
2023-07-15 17:15:38 +00:00
|
|
|
, Carbon, Cocoa, Kernel, OpenGL, fixDarwinDylibNames
|
2024-05-15 15:35:15 +00:00
|
|
|
, extra-cmake-modules, wayland
|
|
|
|
, wayland-scanner, wayland-protocols, libxkbcommon
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2024-05-15 15:35:15 +00:00
|
|
|
version = "3.4";
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "glfw";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "glfw";
|
|
|
|
repo = "GLFW";
|
|
|
|
rev = version;
|
2024-05-15 15:35:15 +00:00
|
|
|
sha256 = "sha256-FcnQPDeNHgov1Z07gjFze0VMz2diOrpbKZCsI96ngz0=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
# Fix linkage issues on X11 (https://github.com/NixOS/nixpkgs/issues/142583)
|
2024-05-15 15:35:15 +00:00
|
|
|
patches = ./x11.patch;
|
2021-07-14 22:03:04 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
propagatedBuildInputs =
|
|
|
|
lib.optionals stdenv.isDarwin [ OpenGL ]
|
|
|
|
++ lib.optionals stdenv.isLinux [ libGL ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
nativeBuildInputs = [ cmake extra-cmake-modules ]
|
2021-07-14 22:03:04 +00:00
|
|
|
++ lib.optional stdenv.isDarwin fixDarwinDylibNames
|
2024-05-15 15:35:15 +00:00
|
|
|
++ lib.optionals stdenv.isLinux [ wayland-scanner ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-07-14 22:03:04 +00:00
|
|
|
buildInputs =
|
2024-01-02 11:29:13 +00:00
|
|
|
lib.optionals stdenv.isDarwin [ Carbon Cocoa Kernel ]
|
2024-05-15 15:35:15 +00:00
|
|
|
++ lib.optionals stdenv.isLinux [
|
|
|
|
wayland
|
|
|
|
wayland-protocols
|
|
|
|
libxkbcommon
|
|
|
|
libX11
|
|
|
|
libXrandr
|
|
|
|
libXinerama
|
|
|
|
libXcursor
|
|
|
|
libXi
|
|
|
|
libXext
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DBUILD_SHARED_LIBS=ON"
|
2024-01-02 11:29:13 +00:00
|
|
|
] ++ lib.optionals (!stdenv.isDarwin && !stdenv.hostPlatform.isWindows) [
|
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
|
|
|
"-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
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
postPatch = lib.optionalString stdenv.isLinux ''
|
2021-07-14 22:03:04 +00:00
|
|
|
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 ];
|
2024-01-02 11:29:13 +00:00
|
|
|
platforms = platforms.unix ++ platforms.windows;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|