diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/glfw')
5 files changed, 195 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/glfw/2.x.nix b/nixpkgs/pkgs/development/libraries/glfw/2.x.nix new file mode 100644 index 000000000000..545e7a418a5f --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glfw/2.x.nix @@ -0,0 +1,32 @@ +{ lib, stdenv, fetchurl, libGLU, libGL, libX11, libXext }: + +stdenv.mkDerivation rec { + pname = "glfw"; + version = "2.7.9"; + + src = fetchurl { + url = "mirror://sourceforge/glfw/glfw-${version}.tar.bz2"; + sha256 = "17c2msdcb7pn3p8f83805h1c216bmdqnbn9hgzr1j8wnwjcpxx6i"; + }; + + buildInputs = [ libGLU libGL libX11 libXext ]; + + buildPhase = '' + make x11 + ''; + + installPhase = '' + mkdir -p $out + make x11-dist-install PREFIX=$out + mv $out/lib/libglfw.so $out/lib/libglfw.so.2 + ln -s libglfw.so.2 $out/lib/libglfw.so + ''; + + meta = with lib; { + description = "Multi-platform library for creating OpenGL contexts and managing input, including keyboard, mouse, joystick and time"; + homepage = "https://glfw.sourceforge.net/"; + license = licenses.zlib; + maintainers = [ lib.maintainers.marcweber ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/glfw/3.x-wayland-minecraft.nix b/nixpkgs/pkgs/development/libraries/glfw/3.x-wayland-minecraft.nix new file mode 100644 index 000000000000..03baa891b3b4 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glfw/3.x-wayland-minecraft.nix @@ -0,0 +1,64 @@ +{ stdenv, lib, fetchFromGitHub, fetchpatch2, cmake, extra-cmake-modules +, libGL, wayland, wayland-protocols, libxkbcommon, libdecor +}: + +stdenv.mkDerivation { + version = "unstable-2023-06-01"; + pname = "glfw-wayland-minecraft"; + + src = fetchFromGitHub { + owner = "glfw"; + repo = "GLFW"; + rev = "3eaf1255b29fdf5c2895856c7be7d7185ef2b241"; + sha256 = "sha256-UnwuE/3q6I4dS5syagpnqrDEVDK9XSVdyOg7KNkdUUA="; + }; + + patches = [ + (fetchpatch2 { + url = "https://raw.githubusercontent.com/Admicos/minecraft-wayland/15f88a515c63a9716cfdf4090fab8e16543f4ebd/0003-Don-t-crash-on-calls-to-focus-or-icon.patch"; + hash = "sha256-NZbKh16h+tWXXnz13QcFBFaeGXMNxZKGQb9xJEahFnE="; + }) + (fetchpatch2 { + url = "https://raw.githubusercontent.com/Admicos/minecraft-wayland/15f88a515c63a9716cfdf4090fab8e16543f4ebd/0005-Add-warning-about-being-an-unofficial-patch.patch"; + hash = "sha256-QMUNlnlCeFz5gIVdbM+YXPsrmiOl9cMwuVRSOvlw+T0="; + }) + ]; + + propagatedBuildInputs = [ libGL ]; + + nativeBuildInputs = [ cmake extra-cmake-modules ]; + + buildInputs = [ wayland wayland-protocols libxkbcommon ]; + + cmakeFlags = [ + "-DBUILD_SHARED_LIBS=ON" + "-DGLFW_BUILD_WAYLAND=ON" + "-DGLFW_BUILD_X11=OFF" + "-DCMAKE_C_FLAGS=-D_GLFW_EGL_LIBRARY='\"${lib.getLib libGL}/lib/libEGL.so.1\"'" + ]; + + postPatch = '' + substituteInPlace src/wl_init.c \ + --replace "libxkbcommon.so.0" "${lib.getLib libxkbcommon}/lib/libxkbcommon.so.0" + + substituteInPlace src/wl_init.c \ + --replace "libdecor-0.so.0" "${lib.getLib libdecor}/lib/libdecor-0.so.0" + + substituteInPlace src/wl_init.c \ + --replace "libwayland-client.so.0" "${lib.getLib wayland}/lib/libwayland-client.so.0" + + substituteInPlace src/wl_init.c \ + --replace "libwayland-cursor.so.0" "${lib.getLib wayland}/lib/libwayland-cursor.so.0" + + substituteInPlace src/wl_init.c \ + --replace "libwayland-egl.so.1" "${lib.getLib wayland}/lib/libwayland-egl.so.1" + ''; + + meta = with lib; { + description = "Multi-platform library for creating OpenGL contexts and managing input, including keyboard, mouse, joystick and time - with patches to support Minecraft on Wayland"; + homepage = "https://www.glfw.org/"; + license = licenses.zlib; + maintainers = with maintainers; [ Scrumplex ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/glfw/3.x.nix b/nixpkgs/pkgs/development/libraries/glfw/3.x.nix new file mode 100644 index 000000000000..014e5f7e9f0e --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glfw/3.x.nix @@ -0,0 +1,56 @@ +{ stdenv, lib, fetchFromGitHub, cmake +, libGL, libXrandr, libXinerama, libXcursor, libX11, libXi, libXext +, Carbon, Cocoa, Kernel, OpenGL, fixDarwinDylibNames +, waylandSupport ? false, extra-cmake-modules, wayland +, wayland-protocols, libxkbcommon +}: + +stdenv.mkDerivation rec { + version = "3.3.10"; + pname = "glfw"; + + src = fetchFromGitHub { + owner = "glfw"; + repo = "GLFW"; + rev = version; + sha256 = "sha256-kTRXsfQ+9PFurG3ffz0lwnITAYAXtNl3h/3O6FSny5o="; + }; + + # Fix linkage issues on X11 (https://github.com/NixOS/nixpkgs/issues/142583) + patches = lib.optional (!waylandSupport) ./x11.patch; + + propagatedBuildInputs = + lib.optionals stdenv.isDarwin [ OpenGL ] + ++ lib.optionals stdenv.isLinux [ libGL ]; + + nativeBuildInputs = [ cmake ] + ++ lib.optional stdenv.isDarwin fixDarwinDylibNames + ++ lib.optional waylandSupport extra-cmake-modules; + + buildInputs = + lib.optionals stdenv.isDarwin [ Carbon Cocoa Kernel ] + ++ lib.optionals (stdenv.isLinux && waylandSupport) [ wayland wayland-protocols libxkbcommon ] + ++ lib.optionals (stdenv.isLinux && !waylandSupport) [ libX11 libXrandr libXinerama libXcursor libXi libXext ]; + + cmakeFlags = [ + "-DBUILD_SHARED_LIBS=ON" + ] ++ lib.optionals (!stdenv.isDarwin && !stdenv.hostPlatform.isWindows) [ + "-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/"; + license = licenses.zlib; + maintainers = with maintainers; [ marcweber twey ]; + platforms = platforms.unix ++ platforms.windows; + }; +} 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 + diff --git a/nixpkgs/pkgs/development/libraries/glfw/x11.patch b/nixpkgs/pkgs/development/libraries/glfw/x11.patch new file mode 100644 index 000000000000..5cadf53bfe70 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glfw/x11.patch @@ -0,0 +1,18 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index a0be580e..ba143851 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -219,6 +219,13 @@ if (GLFW_BUILD_X11) + if (NOT X11_Xshape_INCLUDE_PATH) + message(FATAL_ERROR "X Shape headers not found; install libxext development package") + endif() ++ ++ target_link_libraries(glfw PRIVATE ${X11_Xrandr_LIB} ++ ${X11_Xinerama_LIB} ++ ${X11_Xkb_LIB} ++ ${X11_Xcursor_LIB} ++ ${X11_Xi_LIB} ++ ${X11_Xshape_LIB}) + endif() + + if (UNIX AND NOT APPLE) |