minecraft-wayland
minecraft-wayland copied to clipboard
Guix tutorial
Hey!
Thanks so much for your effort, it's proved to be the only way to run this damned game on wayland with reasonable performance.
I'm on guix, and I built glfw from both branches, with libdecor giving me the results I needed
here is how I got that done
(define-module (gl)
#:use-module (gnu packages kde-frameworks) ; extra-cmake-modules
#:use-module (gnu packages xdisorg) ; xkbcommon
#:use-module (gnu packages gl)
;; ^ for > 3.3.4 + glfw-wayland
#:use-module (gnu packages glib) ; for dbus
#:use-module (gnu packages cmake) ; for cmake
#:use-module (gnu packages gtk) ; for cairo
;; ^ for libdecor
#:use-module (gnu packages)
#:use-module (gnu packages autotools)
#:use-module (gnu packages bison)
#:use-module (gnu packages compression)
#:use-module (gnu packages documentation)
#:use-module (gnu packages elf)
#:use-module (gnu packages flex)
#:use-module (gnu packages fontutils)
#:use-module (gnu packages freedesktop)
#:use-module (gnu packages gettext)
#:use-module (gnu packages guile)
#:use-module (gnu packages image)
#:use-module (gnu packages linux)
#:use-module (gnu packages llvm)
#:use-module (gnu packages mono)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages tls)
#:use-module (gnu packages video)
#:use-module (gnu packages vulkan)
#:use-module (gnu packages xdisorg)
#:use-module (gnu packages xml)
#:use-module (gnu packages xorg)
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix hg-download)
#:use-module (guix build-system gnu)
#:use-module (guix build-system cmake)
#:use-module (guix build-system meson)
#:use-module (guix build-system waf)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module (guix utils)
#:use-module (ice-9 match)
#:use-module ((srfi srfi-1) #:hide (zip)))
;;; guix download https://github.com/glfw/glfw/archive/87d5646f5d2bad0562744501633bf8105f59c193.tar.gz
;;
;; /gnu/store/n3jxq8sp3svskc649b3mcdkq7x4rrx9n-87d5646f5d2bad0562744501633bf8105f59c193.tar.gz
;; 191ayzm3vnnwwwzk6gzrwcxr60n490cv4nvzik9i1483zc69k33v
;; '/var/log/guix/drvs/d3/hjz8nq1s8a0hw8sv7gx3ry1qrbvviy-libdecor-0.1.0.drv.gz'
(define-public libdecor
(package
(name "libdecor")
(version "0.1.0")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://gitlab.gnome.org/jadahl/libdecor.git")
(recursive? #t)
(commit version)))
(file-name (git-file-name name version))
(sha256
(base32
;; cd /tmp && rm -rf libdecor && git clone https://gitlab.gnome.org/jadahl/libdecor.git --recursive && cd libdecor && git checkout 0.1.0 && guix hash -rx .
"0qdg3r7k086wzszr969s0ljlqdvfqm31zpl8p5h397bw076zr6p2"))))
(build-system meson-build-system)
(native-inputs
`(("wayland-client" ,wayland)
("wayland-protocols" ,wayland-protocols)
("dbus" ,dbus)
("pkg-config" ,pkg-config)
("cmake" ,cmake)
("cairo" ,cairo)
("pango" ,pango)
;; EGL
("libgl1-mesa" ,mesa) ;; for libEGL.so
("egl" ,egl-wayland)
("xkbcommon" ,libxkbcommon)
))
(home-page "https://gitlab.gnome.org/jadahl/libdecor.git")
(synopsis "TODO")
(description "TODO")
(license license:expat)))
(define-public glfw
(package
(name "glfw")
(version "3.4.0")
(source (origin
(method url-fetch)
(uri (string-append "https://github.com/glfw/glfw"
;; "/releases/download/" version "/glfw-" version ".zip" ;; with version
"/archive/" "87d5646f5d2bad0562744501633bf8105f59c193" ".tar.gz" ;; with commit
))
(sha256
(base32
;;"1kcrpl4d6b6h23ib5j9q670d9w3knd07whgbanbmwwhbcqnc9lmv" ;; 3.3.4
;;"1097l54cczlg0w9xcgpz9f2wyis58544mv6l28v9y2jcsh2p6ls5" ;; 3.3.6
"191ayzm3vnnwwwzk6gzrwcxr60n490cv4nvzik9i1483zc69k33v" ;; 3.4.0 approximation
))
(patches (search-patches
"0001-Wayland-Set-O_NONBLOCK-on-repeat-timerfd.patch"
"0002-Wayland-Continue-poll-if-timerfd-can-t-be-read.patch"
"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"
;; 0006->0009 are libdecoration
"0006-Don-t-crash-getting-scancode-name.patch"
"0007-libdecor-proper-decorations-with-title-and-window-bu.patch"
"0008-Add-libdecoration-marker-to-stderr-warning.patch"
"0009-Wayland-Fix-cursor-offset-when-shape-changes.patch"
))))
(build-system cmake-build-system)
(arguments
'(#:tests? #f ;; no test target
#:configure-flags
'("-DBUILD_SHARED_LIBS=ON"
"-DGLFW_USE_WAYLAND=ON"
"-DGLFW_USE_LIBDECOR=ON" ;; libdecoration
)))
(native-inputs
(list doxygen unzip))
(propagated-inputs
(list mesa ;included in public headers
;; These are in 'Requires.private' of 'glfw3.pc'.
;;openjdk
libx11
libxrandr
libxi
libxinerama
libxcursor
libxxf86vm
;; 3.3.6
extra-cmake-modules
wayland
wayland-protocols
pkg-config
libxkbcommon
libdecor
))
(home-page "https://www.glfw.org")
(synopsis "OpenGL application development library")
(description
"GLFW is a library for OpenGL, OpenGL ES and Vulkan development for
desktop computers. It provides a simple API for creating windows, contexts
and surfaces, receiving input and events.")
(license license:zlib)))
glfw
dropping this into the repo as glfw.scm
, then running guix package --install-from-file=./glfw.scm
will derive both and yield an installation of glfw.
$ tree /gnu/store/ryrz64w4wjj8l1i00qa1ivjdxvkkliwl-glfw-3.4.0 -I doc
;; /gnu/store/ryrz64w4wjj8l1i00qa1ivjdxvkkliwl-glfw-3.4.0
;; ├── include
;; │ └── GLFW
;; │ ├── glfw3.h
;; │ └── glfw3native.h
;; ├── lib
;; │ ├── cmake
;; │ │ └── glfw3
;; │ │ ├── glfw3Config.cmake
;; │ │ ├── glfw3ConfigVersion.cmake
;; │ │ ├── glfw3Targets.cmake
;; │ │ └── glfw3Targets-relwithdebinfo.cmake
;; │ ├── libglfw.so -> libglfw.so.3
;; │ ├── libglfw.so.3 -> libglfw.so.3.4
;; │ ├── libglfw.so.3.4
;; │ └── pkgconfig
;; │ └── glfw3.pc
;; └── share
;;
;; 7 directories, 10 files
if you depend on a separate glfw version, just rename the package like glfw-latest
or something -- it's irrelevant because multiMC won't detect the 'system glfw' without explicit specification anyway
to find the qualified library path,
$ ls "$(guix package -I glfw | awk '{print $4}')"/lib/libglfw.so
;; /gnu/store/ryrz64w4wjj8l1i00qa1ivjdxvkkliwl-glfw-3.4.0/lib/libglfw.so
then add the relevant arg to the java opts
-Dorg.lwjgl.glfw.libname=/gnu/store/ryrz64w4wjj8l1i00qa1ivjdxvkkliwl-glfw-3.4.0/lib/libglfw.so
and that should suffice! I had a couple choppy runs which were chugging at 5-10 fps, but after my first reboot post-build I've never seen anything like the monstrous framebuffer->renderbuffer lag with xwayland.
- I haven't had any success launching with my dedi gpu, as I'm in the process of extending the 495+ driver support in nonguix[1] from nvdia which includes GBM support as well as that EGL hill they're dying on -- nouveau performance is worse than integrated intel graphics, but you can target the GPU by running java, or more convenienly, multimc, with
DRI_PRIME=1 DevLauncher
, so, there's that
[1] https://gitlab.com/nonguix/nonguix/-/raw/master/nongnu/packages/nvidia.scm
also https://www.phoronix.com/forums/forum/linux-graphics-x-org-drivers/wayland-display-server/1298124-sway-1-7-rc1-has-better-zero-copy-direct-scanout-drops-my-next-gpu-wont-be-nvidia
and this salty megathread about 495 https://forums.developer.nvidia.com/t/nvidia-495-on-sway-tutorial-questions-arch-based-distros/192212/66
thanks again, you're my hero!
Added a link to the README. I'll keep this issue open for discussion
Hi! I've made some minor modifications to the package so it applies the patches from the current one-nineteen branch and the 1.19 libdecor pull request (although I haven't tested if libdecor works since I'm on Plasma).
Here's the modified code:
(define-module (gl)
#:use-module (gnu packages kde-frameworks) ; extra-cmake-modules
#:use-module (gnu packages xdisorg) ; xkbcommon
#:use-module (gnu packages gl)
;; ^ for > 3.3.4 + glfw-wayland
#:use-module (gnu packages glib) ; for dbus
#:use-module (gnu packages cmake) ; for cmake
#:use-module (gnu packages gtk) ; for cairo
;; ^ for libdecor
#:use-module (gnu packages)
#:use-module (gnu packages autotools)
#:use-module (gnu packages bison)
#:use-module (gnu packages compression)
#:use-module (gnu packages documentation)
#:use-module (gnu packages elf)
#:use-module (gnu packages flex)
#:use-module (gnu packages fontutils)
#:use-module (gnu packages freedesktop)
#:use-module (gnu packages gettext)
#:use-module (gnu packages guile)
#:use-module (gnu packages image)
#:use-module (gnu packages linux)
#:use-module (gnu packages llvm)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages tls)
#:use-module (gnu packages video)
#:use-module (gnu packages vulkan)
#:use-module (gnu packages xdisorg)
#:use-module (gnu packages xml)
#:use-module (gnu packages xorg)
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix hg-download)
#:use-module (guix build-system gnu)
#:use-module (guix build-system cmake)
#:use-module (guix build-system meson)
#:use-module (guix build-system waf)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module (guix utils)
#:use-module (ice-9 match)
#:use-module ((srfi srfi-1) #:hide (zip)))
(define-public libdecor
(package
(name "libdecor")
(version "0.1.0")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://gitlab.gnome.org/jadahl/libdecor.git")
(recursive? #t)
(commit version)))
(file-name (git-file-name name version))
(sha256
(base32
;; cd /tmp && rm -rf libdecor && git clone https://gitlab.gnome.org/jadahl/libdecor.git --recursive && cd libdecor && git checkout 0.1.0 && guix hash -rx .
"0qdg3r7k086wzszr969s0ljlqdvfqm31zpl8p5h397bw076zr6p2"))))
(build-system meson-build-system)
(native-inputs
(list wayland
wayland-protocols
dbus
pkg-config
cmake
cairo
pango
mesa ;; for libEGL.so
egl-wayland
libxkbcommon))
(home-page "https://gitlab.gnome.org/jadahl/libdecor.git")
(synopsis "TODO")
(description "TODO")
(license license:expat)))
(define-public glfw-wayland-minecraft
(package
(name "glfw-wayland-minecraft")
(version "3.4.0")
(source
(origin (method url-fetch)
(uri (string-append
"https://github.com/glfw/glfw/archive/"
"62e175ef9fae75335575964c845a302447c012c7" ;; commit
".tar.gz"))
(sha256
(base32
"1zlbc4jyxgpll8vnaq382fa92r98y84prcdk15bqi6fygb2rd3wq"))
(patches
(search-patches
;; https://github.com/Admicos/minecraft-wayland/tree/bdc3c0d192097459eb4e72b26c8267f82266e951
"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"
;; "0006-Don-t-crash-getting-scancode-name.patch" ;; BROKEN
"0007-Platform-Prefer-Wayland-over-X11.patch"
;; https://github.com/Admicos/minecraft-wayland/pull/29
"0008-libdecor-proper-decorations-with-title-and-window-bu.patch"
"0009-Add-libdecoration-marker-to-stderr-warning.patch"))))
(build-system cmake-build-system)
(arguments
'(#:tests? #f ;; no test target
#:configure-flags
'("-DBUILD_SHARED_LIBS=ON"
"-DGLFW_USE_WAYLAND=ON"
"-DGLFW_USE_LIBDECOR=ON" ;; libdecoration
)))
(native-inputs
(list pkg-config
doxygen
unzip
mesa
extra-cmake-modules
wayland-protocols
libxrandr
libxi
libxinerama
libxcursor
libdecor))
(inputs
(list wayland
libxkbcommon))
(propagated-inputs
(list ;; These are in 'Requires.private' of 'glfw3.pc'.
;;openjdk
libx11
libxxf86vm))
(home-page "https://www.glfw.org")
(synopsis "OpenGL application development library")
(description
"GLFW is a library for OpenGL, OpenGL ES and Vulkan development for
desktop computers. It provides a simple API for creating windows, contexts
and surfaces, receiving input and events.")
(license license:zlib)))
glfw-wayland-minecraft
This definition should work with the instructions provided in the original comment after switching to the one-nineteen branch and including the additional patch files from pull request #29.
Cheers!