From 6a0d199b347004d9afbc808c7fc7b3b1673acc23 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Wed, 8 Feb 2023 22:28:04 -0500 Subject: [PATCH] glfw-wayland-minecraft --- modules/linux/programs/games.nix | 29 +---------- ...on-t-crash-on-calls-to-focus-or-icon.patch | 0 ...-broken-opengl-screenshots-on-mutter.patch | 0 ...ning-about-being-an-unofficial-patch.patch | 0 ...06-Don-t-crash-getting-scancode-name.patch | 0 ...007-Platform-Prefer-Wayland-over-X11.patch | 0 packages/glfw-minecraft-wayland/default.nix | 49 +++++++++++++++++++ 7 files changed, 51 insertions(+), 27 deletions(-) rename {patches/minecraft => packages/glfw-minecraft-wayland}/0003-Don-t-crash-on-calls-to-focus-or-icon.patch (100%) rename {patches/minecraft => packages/glfw-minecraft-wayland}/0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch (100%) rename {patches/minecraft => packages/glfw-minecraft-wayland}/0005-Add-warning-about-being-an-unofficial-patch.patch (100%) rename {patches/minecraft => packages/glfw-minecraft-wayland}/0006-Don-t-crash-getting-scancode-name.patch (100%) rename {patches/minecraft => packages/glfw-minecraft-wayland}/0007-Platform-Prefer-Wayland-over-X11.patch (100%) create mode 100644 packages/glfw-minecraft-wayland/default.nix diff --git a/modules/linux/programs/games.nix b/modules/linux/programs/games.nix index 3aaf40f..b158b57 100644 --- a/modules/linux/programs/games.nix +++ b/modules/linux/programs/games.nix @@ -4,33 +4,8 @@ in with lib; { config = mkIf np.games { environment.systemPackages = let # https://github.com/Admicos/minecraft-wayland - glfw-patched = pkgs.glfw-wayland.overrideAttrs (attrs: { - src = pkgs.fetchzip { - version = "3.4.0"; - url = - "https://github.com/glfw/glfw/archive/62e175ef9fae75335575964c845a302447c012c7.tar.gz"; - sha256 = "sha256-GiY4d7xadR0vN5uCQyWaOpoo2o6uMGl1fCcX4uDGnks="; - }; - buildInputs = with pkgs; - with pkgs.xorg; [ - wayland - wayland-protocols - libxkbcommon - libX11 - libXrandr - libXinerama - libXcursor - libXi - libXext - ]; - patches = [ - ../../../patches/minecraft/0003-Don-t-crash-on-calls-to-focus-or-icon.patch - ../../../patches/minecraft/0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch - ../../../patches/minecraft/0005-Add-warning-about-being-an-unofficial-patch.patch - # ../../../patches/minecraft/0006-Don-t-crash-getting-scancode-name.patch - ../../../patches/minecraft/0007-Platform-Prefer-Wayland-over-X11.patch - ]; - }); + glfw-patched = + pkgs.callPackage ../../../packages/glfw-minecraft-wayland { }; stable-packages = with pkgs; [ # Dwarf fortress (dwarf-fortress-packages.dwarf-fortress-full.override { diff --git a/patches/minecraft/0003-Don-t-crash-on-calls-to-focus-or-icon.patch b/packages/glfw-minecraft-wayland/0003-Don-t-crash-on-calls-to-focus-or-icon.patch similarity index 100% rename from patches/minecraft/0003-Don-t-crash-on-calls-to-focus-or-icon.patch rename to packages/glfw-minecraft-wayland/0003-Don-t-crash-on-calls-to-focus-or-icon.patch diff --git a/patches/minecraft/0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch b/packages/glfw-minecraft-wayland/0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch similarity index 100% rename from patches/minecraft/0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch rename to packages/glfw-minecraft-wayland/0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch diff --git a/patches/minecraft/0005-Add-warning-about-being-an-unofficial-patch.patch b/packages/glfw-minecraft-wayland/0005-Add-warning-about-being-an-unofficial-patch.patch similarity index 100% rename from patches/minecraft/0005-Add-warning-about-being-an-unofficial-patch.patch rename to packages/glfw-minecraft-wayland/0005-Add-warning-about-being-an-unofficial-patch.patch diff --git a/patches/minecraft/0006-Don-t-crash-getting-scancode-name.patch b/packages/glfw-minecraft-wayland/0006-Don-t-crash-getting-scancode-name.patch similarity index 100% rename from patches/minecraft/0006-Don-t-crash-getting-scancode-name.patch rename to packages/glfw-minecraft-wayland/0006-Don-t-crash-getting-scancode-name.patch diff --git a/patches/minecraft/0007-Platform-Prefer-Wayland-over-X11.patch b/packages/glfw-minecraft-wayland/0007-Platform-Prefer-Wayland-over-X11.patch similarity index 100% rename from patches/minecraft/0007-Platform-Prefer-Wayland-over-X11.patch rename to packages/glfw-minecraft-wayland/0007-Platform-Prefer-Wayland-over-X11.patch diff --git a/packages/glfw-minecraft-wayland/default.nix b/packages/glfw-minecraft-wayland/default.nix new file mode 100644 index 0000000..bf71665 --- /dev/null +++ b/packages/glfw-minecraft-wayland/default.nix @@ -0,0 +1,49 @@ +{ stdenv, lib, fetchzip, cmake, libGL, libXrandr, libXinerama, libXcursor +, libX11, libXi, libXext, extra-cmake-modules, wayland, wayland-protocols +, libxkbcommon }: +stdenv.mkDerivation rec { + version = "3.4.0+1.19"; + pname = "glfw"; + + src = fetchzip { + url = + "https://github.com/glfw/glfw/archive/62e175ef9fae75335575964c845a302447c012c7.tar.gz"; + sha256 = "sha256-GiY4d7xadR0vN5uCQyWaOpoo2o6uMGl1fCcX4uDGnks="; + }; + + patches = [ + ./0003-Don-t-crash-on-calls-to-focus-or-icon.patch + ./0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch + ./0005-Add-warning-about-being-an-unofficial-patch.patch + ./0007-Platform-Prefer-Wayland-over-X11.patch + ]; + + propagatedBuildInputs = + [ libGL libX11 libXrandr libXinerama libXcursor libXi libXext ]; + nativeBuildInputs = [ cmake extra-cmake-modules ]; + buildInputs = [ wayland wayland-protocols libxkbcommon ]; + + cmakeFlags = [ + "-DBUILD_SHARED_LIBS=ON" + "-DGLFW_USE_WAYLAND=ON" + "-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" + ''; + + 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; + }; +}