21 , withMinecraftPatch ? false
27 pname = "glfw${lib.optionalString withMinecraftPatch "-minecraft"}";
30 src = fetchFromGitHub {
34 hash = "sha256-FcnQPDeNHgov1Z07gjFze0VMz2diOrpbKZCsI96ngz0=";
37 # Fix linkage issues on X11 (https://github.com/NixOS/nixpkgs/issues/142583)
40 ] ++ lib.optionals withMinecraftPatch [
41 ./0009-Defer-setting-cursor-position-until-the-cursor-is-lo.patch
44 propagatedBuildInputs = lib.optionals (!stdenv.hostPlatform.isWindows) [ libGL ];
46 nativeBuildInputs = [ cmake pkg-config ]
47 ++ lib.optionals stdenv.hostPlatform.isDarwin [ fixDarwinDylibNames ]
48 ++ lib.optionals stdenv.hostPlatform.isLinux [ wayland-scanner ];
51 lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [ Carbon Cocoa Kernel ])
52 ++ lib.optionals stdenv.hostPlatform.isLinux [
65 "-DBUILD_SHARED_LIBS=ON"
66 ] ++ lib.optionals (!stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isWindows) [
67 "-DCMAKE_C_FLAGS=-D_GLFW_GLX_LIBRARY='\"${lib.getLib libGL}/lib/libGL.so.1\"'"
68 "-DCMAKE_C_FLAGS=-D_GLFW_EGL_LIBRARY='\"${lib.getLib libGL}/lib/libEGL.so.1\"'"
69 "-DCMAKE_C_FLAGS=-D_GLFW_VULKAN_LIBRARY='\"${lib.getLib vulkan-loader}/lib/libvulkan.so.1\"'"
72 postPatch = lib.optionalString stdenv.hostPlatform.isLinux ''
73 substituteInPlace src/wl_init.c \
74 --replace-fail "libxkbcommon.so.0" "${lib.getLib libxkbcommon}/lib/libxkbcommon.so.0" \
75 --replace-fail "libdecor-0.so.0" "${lib.getLib libdecor}/lib/libdecor-0.so.0" \
76 --replace-fail "libwayland-client.so.0" "${lib.getLib wayland}/lib/libwayland-client.so.0" \
77 --replace-fail "libwayland-cursor.so.0" "${lib.getLib wayland}/lib/libwayland-cursor.so.0" \
78 --replace-fail "libwayland-egl.so.1" "${lib.getLib wayland}/lib/libwayland-egl.so.1"
81 # glfw may dlopen libwayland-client.so:
82 postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
83 patchelf ''${!outputLib}/lib/libglfw.so --add-rpath ${lib.getLib wayland}/lib
87 description = "Multi-platform library for creating OpenGL contexts and managing input, including keyboard, mouse, joystick and time";
88 homepage = "https://www.glfw.org/";
89 license = licenses.zlib;
90 maintainers = with maintainers; [ marcweber Scrumplex twey ];
91 platforms = platforms.unix ++ platforms.windows;