games.scm 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. ;;; Copyright © 2018-2021 Kei Kebreau <kkebreau@posteo.net>
  2. ;;;
  3. ;;; This program is free software; you can redistribute it and/or modify it
  4. ;;; under the terms of the GNU General Public License as published by
  5. ;;; the Free Software Foundation; either version 3 of the License, or (at
  6. ;;; your option) any later version.
  7. ;;;
  8. ;;; This program is distributed in the hope that it will be useful, but
  9. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;;; GNU General Public License for more details.
  12. ;;;
  13. ;;; You should have received a copy of the GNU General Public License
  14. ;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. (define-module (games)
  16. #:use-module (guix packages)
  17. #:use-module (gnu packages)
  18. #:use-module ((guix licenses) #:prefix license:)
  19. #:use-module (guix download)
  20. #:use-module (guix utils)
  21. #:use-module (guix git-download)
  22. #:use-module (guix build-system cmake)
  23. #:use-module (guix build-system gnu)
  24. #:use-module (gnu packages compression)
  25. #:use-module (gnu packages curl)
  26. #:use-module (gnu packages glib)
  27. #:use-module (gnu packages gtk)
  28. #:use-module (gnu packages image)
  29. #:use-module (gnu packages music)
  30. #:use-module (gnu packages ncurses)
  31. #:use-module (gnu packages pkg-config)
  32. #:use-module (gnu packages sdl))
  33. (define-public dopewars
  34. (package
  35. (name "dopewars")
  36. (version "1.5.12")
  37. (source
  38. (origin
  39. (method url-fetch)
  40. (uri (string-append "mirror://sourceforge/dopewars/dopewars/"
  41. version "/dopewars-" version ".tar.gz"))
  42. (sha256
  43. (base32 "068cxvz51l9rh8nkn2z9bdg57wvy4dv1vqlf2hmhgilnxb6rs193"))
  44. (modules '((guix build utils)))
  45. (snippet
  46. '(begin
  47. (substitute* "src/plugins/sound_sdl.c"
  48. (("SDL_mixer\\.h") "SDL/SDL_mixer.h"))
  49. #t))))
  50. (build-system gnu-build-system)
  51. (arguments
  52. `(#:configure-flags '("--disable-static")
  53. #:phases
  54. (modify-phases %standard-phases
  55. (add-after 'unpack 'set-score-dir
  56. (lambda _
  57. (substitute* "src/dopewars.c"
  58. (("DPSCOREDIR") "\"~/.local/share/dopewars\""))
  59. #t))
  60. (add-after 'install 'wrap-program
  61. (lambda _
  62. (let* ((output (assoc-ref %outputs "out"))
  63. (dopewars-script (string-append output "/bin/dopewars")))
  64. (rename-file (string-append output "/bin/dopewars")
  65. (string-append output "/bin/.dopewars-real"))
  66. (call-with-output-file dopewars-script
  67. (lambda (port)
  68. (format port "#!~a/bin/sh
  69. if [ ! -d ~~/.local/share/dopewars ]; then
  70. mkdir -p ~~/.local/share/dopewars
  71. cp ~a/var/dopewars.sco ~~/.local/share/dopewars/dopewars.sco
  72. chmod -R +w ~~/.local/share/dopewars
  73. fi
  74. exec -a -- ~a/bin/.dopewars-real -f ~~/.local/share/dopewars/dopewars.sco \"$@\"~%"
  75. (assoc-ref %build-inputs "bash")
  76. output
  77. output)))
  78. (chmod dopewars-script #o555)
  79. #t))))))
  80. (native-inputs
  81. `(("pkg-config" ,pkg-config)))
  82. (inputs
  83. `(("glib" ,glib)
  84. ("gtk+" ,gtk+-2)
  85. ("ncurses" ,ncurses)
  86. ("sdl-union" ,(sdl-union (list sdl sdl-mixer)))))
  87. (home-page "https://dopewars.sourceforge.io/")
  88. (synopsis "Drug dealing game")
  89. (description
  90. "dopewars is a rewrite of a game originally based on \"Drug Wars\" by John
  91. E. Dell. The idea of dopewars is to deal in drugs on the streets of New York,
  92. amassing a huge fortune and paying off the loan shark, while avoiding the
  93. ever-annoying police. The rewrite, as well as featuring a so-called
  94. \"antique\" mode which closely follows the original, introduces new features
  95. such as the ability to take part in multi-player games.")
  96. (license license:gpl2+)))
  97. (define-public srb2
  98. (package
  99. (name "srb2")
  100. (version "2.2.8")
  101. (source
  102. (origin
  103. (method git-fetch)
  104. (uri (git-reference
  105. (url "https://github.com/STJr/SRB2.git")
  106. (commit (string-append "SRB2_release_" version))))
  107. (sha256
  108. (base32 "10prk617pbxkpiyybwwjzv425pkjczfqdb8pxwfyq91aa2rg0kl8"))
  109. (file-name (git-file-name name version))
  110. (modules '((guix build utils)))
  111. ;; Remove bundled libraries.
  112. (snippet
  113. '(begin
  114. (delete-file-recursively "libs")
  115. #t))))
  116. (build-system cmake-build-system)
  117. (arguments
  118. `(#:tests? #f ; no check target
  119. #:configure-flags
  120. (list
  121. (string-append "-DGME_INCLUDE_DIR="
  122. (assoc-ref %build-inputs "libgme") "/include/gme")
  123. (string-append "-DSDL2_INCLUDE_DIR="
  124. (assoc-ref %build-inputs "sdl2") "/include/SDL2")
  125. (string-append "-DCMAKE_INSTALL_PREFIX="
  126. (assoc-ref %outputs "out") "/bin")
  127. "-DSRB2_CONFIG_HAVE_OPENMPT=OFF")
  128. #:phases
  129. (modify-phases %standard-phases
  130. (add-after 'unpack 'unpack-data
  131. (lambda* (#:key inputs #:allow-other-keys)
  132. (let* ((p7zip (assoc-ref inputs "p7zip"))
  133. (7z (string-append p7zip "/bin/7z"))
  134. (srb2-data (assoc-ref inputs "srb2-data")))
  135. (mkdir-p "assets/installer")
  136. (and (invoke 7z "e" srb2-data "-oassets/installer"
  137. "music.dta" "patch.pk3" "patch_music.pk3"
  138. "player.dta" "srb2.pk3" "zones.pk3")))))
  139. (add-after 'unpack 'patch-search-locations
  140. (lambda* (#:key outputs #:allow-other-keys)
  141. (let* ((out (assoc-ref outputs "out"))
  142. (share (string-append out "/share/srb2")))
  143. (substitute* '("src/sdl/i_ttf.c"
  144. "src/sdl/i_system.c")
  145. (("/usr/local/share/fonts") share)
  146. (("/usr/share/fonts") share)
  147. (("/usr/local/games/SRB2") share)
  148. (("/usr/local/share/games/SRB2") share)
  149. (("/usr/share/games/SRB2") share))
  150. #t)))
  151. (add-after 'install 'move-files
  152. (lambda* (#:key inputs outputs #:allow-other-keys)
  153. (let* ((out (assoc-ref outputs "out"))
  154. (bin (string-append out "/bin"))
  155. (share (string-append out "/share/srb2")))
  156. (mkdir-p share)
  157. (chdir (string-append "../srb2-" ,version "-checkout"))
  158. (copy-file "src/sdl/srb2.ttf" (string-append share "/srb2.ttf"))
  159. (for-each (lambda (file)
  160. (rename-file (string-append bin "/" file)
  161. (string-append share "/" file)))
  162. '("music.dta" "player.dta" "srb2.pk3" "zones.pk3"
  163. "patch.pk3" "patch_music.pk3"))
  164. #t))))))
  165. (native-inputs
  166. `(("p7zip" ,p7zip)
  167. ("pkg-config" ,pkg-config)
  168. ;; This seems to be the best possible way to get the game data.
  169. ("srb2-data"
  170. ,(origin
  171. (method url-fetch)
  172. (uri
  173. (string-append
  174. "https://github.com/STJr/SRB2/releases/download/SRB2_release_"
  175. version "/SRB2-v" version "-Full.zip"))
  176. (sha256
  177. (base32 "066p2k0ysl97kkf8pm4p8hrrw9i7b7if77ra8fv2vm3v2aqhaf3s"))))))
  178. (inputs
  179. `(("curl" ,curl)
  180. ("libgme" ,libgme)
  181. ("libpng" ,libpng)
  182. ("sdl2" ,sdl2)
  183. ("sdl2-mixer" ,sdl2-mixer)
  184. ("zlib" ,zlib)))
  185. (home-page "https://srb2.org")
  186. (synopsis "3D Sonic the Hedgehog fangame based on Doom Legacy")
  187. (description
  188. "Sonic Robo Blast 2 is a 3D Sonic the Hedgehog fangame built using a
  189. modified version of the Doom Legacy port of Doom. SRB2 is closely inspired by
  190. the original Sonic games from the Sega Genesis, and attempts to recreate the
  191. design in 3D. While SRB2 isn't fully completed, it already features tons of
  192. levels, enemies, speed, and quite a lot of the fun that the original Sonic
  193. games provided.")
  194. (license license:gpl2)))
  195. srb2