channel

My GNU Guix channel
Log | Files | Refs | README

games.scm (7118B)


      1 (define-module (loquat packages games)
      2   #:use-module ((guix licenses) #:prefix license:)
      3   #:use-module (guix packages)
      4   #:use-module (guix git-download)
      5   #:use-module (gnu packages audio)
      6   #:use-module (gnu packages compression)
      7   #:use-module (gnu packages elf)
      8   #:use-module (gnu packages gl)
      9   #:use-module (gnu packages image)
     10   #:use-module (gnu packages java)
     11   #:use-module (gnu packages kde-frameworks)
     12   #:use-module (gnu packages libedit)
     13   #:use-module (gnu packages ncurses)
     14   #:use-module (gnu packages pkg-config)
     15   #:use-module (gnu packages pulseaudio)
     16   #:use-module (gnu packages qt)
     17   #:use-module (gnu packages sdl)
     18   #:use-module (gnu packages speech)
     19   #:use-module (gnu packages sqlite)
     20   #:use-module (gnu packages video)
     21   #:use-module (guix build-system cmake)
     22   #:use-module (guix build-system qt)
     23   #:use-module (guix download)
     24   #:use-module (guix gexp))
     25 
     26 ;; Controller patches for GLFW 3.4
     27 ;; Pulled from https://github.com/mdqinc/SDL_GameControllerDB
     28 
     29 ;; Mappings for the 8BitDo Ultimate 2C controller.
     30 (define 8bitdo-ultimate-2c-patch
     31   (plain-file "8bitdo-ultimate-2c-glfw-3.4.patch" "\
     32 --- a/src/mappings.h	2025-10-23 11:33:49.165631631 -0400
     33 +++ b/src/mappings.h	2025-10-23 11:35:10.850409920 -0400
     34 @@ -996,6 +996,9 @@
     35  \"03000000c0160000e105000001010000,Xin-Mo Xin-Mo Dual Arcade,a:b4,b:b3,back:b6,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b9,leftshoulder:b2,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b1,y:b0,platform:Linux,\",
     36  \"03000000120c0000100e000011010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,\",
     37  \"03000000120c0000101e000011010000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,\",
     38 +\"03000000c82d00000a31000014010000,8BitDo Ultimate 2C,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,\",
     39 +\"03000000c82d00001d30000011010000,8BitDo Ultimate 2C,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,paddle1:b5,paddle2:b2,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,\",
     40 +\"05000000c82d00001b30000001000000,8BitDo Ultimate 2C,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,paddle1:b5,paddle2:b2,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,\"
     41  #endif // GLFW_BUILD_LINUX_JOYSTICK
     42  };"))
     43 
     44 ;; Custom build of GLFW with more controllers included.
     45 ;; This is important for forks like BTA! which implement controller support
     46 ;; using the provided GLFW version.
     47 
     48 (define-public glfw-mc
     49   (package
     50     (inherit glfw-3.4)
     51     (name "glfw-mc")
     52     (version "3.4")
     53     (source (origin
     54               (method url-fetch)
     55               (uri (string-append "https://github.com/glfw/glfw"
     56                                   "/releases/download/" version
     57                                   "/glfw-" version ".zip"))
     58               (sha256
     59                (base32
     60                 "1sd396kkn53myp61kxrd18h7b1q4ix173hhxhvl0iz8j4x5h1v5m"))
     61               (patches (list 8bitdo-ultimate-2c-patch))))
     62     (synopsis "A patched version of GLFW 3.4 that works better with Minecraft
     63 out of the box. Intended to replace the bundled version.")))
     64 
     65 ;; For playing Minecraft. Setup to run on Wayland by default.
     66 ;; TODO: Support X11 out of the box.
     67 (define-public prismlauncher
     68   (package
     69     (name "prismlauncher")
     70     (version "9.4")
     71     (source
     72       (origin
     73         (method git-fetch)
     74         (uri (git-reference
     75               (url "https://github.com/PrismLauncher/PrismLauncher")
     76               (recursive? #t)
     77               (commit version)))
     78         (file-name (git-file-name name version))
     79         (sha256
     80          (base32
     81           "1xxgyx0z5r3hk3yk4gglbfwvq2qk1j9a0dkrv55j4vrlkni79nrm"))))
     82     (build-system cmake-build-system)
     83     (arguments
     84      `(#:phases
     85        (modify-phases %standard-phases
     86          ;; Patch default settings to use native libraries
     87          (add-after 'unpack 'change-default-settings
     88            (lambda* (#:key inputs #:allow-other-keys)
     89              (substitute* "launcher/Application.cpp"
     90                (("\"UseNativeGLFW\", false") 
     91                 "\"UseNativeGLFW\", true")
     92                (("\"UseNativeOpenAL\", false")
     93                 "\"UseNativeOpenAL\", true"))))
     94          ;; Add required environment variables
     95          (add-after 'install 'patch-paths
     96            (lambda* (#:key inputs outputs #:allow-other-keys)
     97              (let* ((out            (assoc-ref outputs "out"))
     98                     (bin            (string-append out "/bin/prismlauncher"))
     99                     (jdk21          (assoc-ref inputs "jdk21"))
    100                     (jdk17          (assoc-ref inputs "jdk17"))
    101                     (qtwayland      (assoc-ref inputs "qtwayland"))
    102                     (qtsvg          (assoc-ref inputs "qtsvg")))
    103                (wrap-program bin
    104                  ;; Add all the OpenJDK versions for Minecraft as needed
    105                  `("PRISMLAUNCHER_JAVA_PATHS" ":" suffix (,(string-append jdk21 "/bin/java")
    106                                                           ,(string-append jdk17 "/bin/java")))
    107                  ;; Fix QT plugins (primarily for wayland support)
    108                  `("QT_PLUGIN_PATH" ":" prefix ,(map (lambda (package)
    109                                                        (string-append package "/lib/qt6/plugins"))
    110                                                      (list qtwayland qtsvg)))
    111                  ;; Add runtime libraries for MC
    112                  `("LD_LIBRARY_PATH" ":" prefix
    113                    (,@(map (lambda (dep)
    114                              (string-append (assoc-ref inputs dep)
    115                                           "/lib"))
    116                            '("glfw" "mesa" "pulseaudio" "openal" "flite")))))
    117                #t))))))
    118     (native-inputs (list pkg-config extra-cmake-modules))
    119     (inputs
    120      `(("zlib" ,zlib)
    121        ("qtbase" ,qtbase)
    122        ("qt5compat" ,qt5compat)
    123        ("qtnetworkauth" ,qtnetworkauth)
    124        ("qtwayland" ,qtwayland)
    125        ("qtsvg" ,qtsvg)
    126        ;; Java versions to include
    127        ("jdk17" ,openjdk17 "jdk")
    128        ("jdk21" ,openjdk21 "jdk")
    129        ;; Runtime deps for MC itself
    130        ("glfw" ,glfw-mc)
    131        ("mesa" ,mesa)
    132        ("flite" ,flite) ;; For narrator
    133        ("openal" ,openal)
    134        ("pulseaudio" ,pulseaudio)))
    135     (home-page "https://prismlauncher.org/")
    136     (synopsis #f)
    137     (description #f)
    138     (license #f)))