summaryrefslogtreecommitdiff
path: root/tw/packages/games.scm
diff options
context:
space:
mode:
Diffstat (limited to 'tw/packages/games.scm')
-rw-r--r--tw/packages/games.scm293
1 files changed, 133 insertions, 160 deletions
diff --git a/tw/packages/games.scm b/tw/packages/games.scm
index 7adee44f..bdadf2b0 100644
--- a/tw/packages/games.scm
+++ b/tw/packages/games.scm
@@ -2,11 +2,8 @@
#:use-module (guile) ; for `geiser-eval-buffer-and-go' to work properly
#:use-module ((ice-9 string-fun) #:select (string-replace-substring))
#:use-module (gnu packages audio)
- #:use-module (gnu packages base)
#:use-module (gnu packages compression)
- #:use-module (gnu packages fonts)
#:use-module (gnu packages fontutils)
- #:use-module (gnu packages gcc)
#:use-module (gnu packages guile)
#:use-module (gnu packages image)
#:use-module (gnu packages pkg-config)
@@ -19,177 +16,153 @@
#:use-module (guix download)
#:use-module (guix gexp)
#:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix modules)
#:use-module (guix packages))
(define-public simutrans-pak128
;; Install paks as propagated-inputs of simutrans, so they go in
;; Simutrans' data directory, where Simutrans expects them.
(package
- (name "simutrans-pak128") ; note: needs simutrans >= 123
- (version "2.8.2")
- (source (origin
- (method url-fetch)
- (uri (string-append
- "mirror://sourceforge/simutrans/pak128/"
- "pak128%202.8.2%20for%20ST%20123up/simupak128-2.8.2-for123.zip"))
- (sha256 (base32 "0hzpb6bh1lh0fdcpxlbfw5j74xz65gxl8yx5094rqf5zflvz10py"))))
- (native-inputs (list unzip)) ; shouldn't copy-build-system / origin handle this?
- (build-system copy-build-system)
- (arguments '(#:install-plan '(("pak128" "share/games/simutrans/pak128"))))
- (home-page "https://forum.simutrans.com/index.php?board=26.0")
- (synopsis "Graphical pak set for Simutrans, 128x128 tile size")
- (description
- (string-append
- "When Simutrans could only support 64px size graphics, pak128 already started. "
- "First pak to feature a complex economy and have a very wide variety of objects. "
- "It contains roughly 7 times more graphic data than pak64 and thus requires by far "
- "the largest amount of RAM and processing power of all Simutrans sets."))
- (license license:artistic2.0)))
+ (name "simutrans-pak128") ; note: needs simutrans >= 123
+ (version "2.8.2")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append
+ "mirror://sourceforge/simutrans/pak128/"
+ "pak128%202.8.2%20for%20ST%20123up/simupak128-2.8.2-for123.zip"))
+ (sha256 (base32 "0hzpb6bh1lh0fdcpxlbfw5j74xz65gxl8yx5094rqf5zflvz10py"))))
+ (native-inputs (list unzip)) ; shouldn't copy-build-system / origin handle this?
+ (build-system copy-build-system)
+ (arguments '(#:install-plan '(("pak128" "share/games/simutrans/pak128"))))
+ (home-page "https://forum.simutrans.com/index.php?board=26.0")
+ (synopsis "Graphical pak set for Simutrans, 128x128 tile size")
+ (description
+ (string-append
+ "When Simutrans could only support 64px size graphics, pak128 already started. "
+ "First pak to feature a complex economy and have a very wide variety of objects. "
+ "It contains roughly 7 times more graphic data than pak64 and thus requires by far "
+ "the largest amount of RAM and processing power of all Simutrans sets."))
+ (license license:artistic2.0)))
-(define simutrans-paths-patch
- (plain-file "simutrans-paths.patch" "\
-This patch stores user-specific config in $XDG_CONFIG_HOME/simutrans
-rather than ~/simutrans.
-
---- a/sys/simsys.cc 2022-09-25 01:36:18.951636483 +0200
-+++ b/sys/simsys.cc 2022-09-25 01:36:44.615457050 +0200
-@@ -395,7 +395,11 @@
- #elif defined __ANDROID__
- tstrncpy(buffer,SDL_GetPrefPath(\"Simutrans Team\",\"simutrans\"),lengthof(buffer));
- #else
-- sprintf(buffer, \"%s/simutrans\", getenv(\"HOME\"));
-+ if (getenv(\"XDG_CONFIG_HOME\") == NULL) {
-+ sprintf(buffer, \"%s/.config/simutrans\", getenv(\"HOME\"));
-+ } else {
-+ sprintf(buffer, \"%s/simutrans\", getenv(\"XDG_CONFIG_HOME\"));
-+ }
- #endif
-
- // create directory and subdirectories
-"))
-
-(define simutrans-desktop-entry "\
-[Desktop Entry]
-Name=Simutrans
-Comment=Transportation simulator
-Exec=simutrans
-Icon=simutrans
-Terminal=false
-Type=Application
-Categories=Game;Simulation;
-")
-
-(define simutrans-appdata-xml "\
-<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-<component type=\"desktop-application\">
-<id>com.simutrans.simutrans</id>
-<launchable type=\"desktop-id\">simutrans.desktop</launchable>
-<name>Simutrans</name>
-<summary>Transportation simulator</summary>
-<metadata_license>CC0-1.0</metadata_license>
-<project_license>Artistic-1.0</project_license>
-<description>
-<p>Simutrans is a free transportation simulator: the player operates a transportation \
-company and has to transport goods and passengers between factories and different cities.</p>
-</description>
-<screenshots>
-<screenshot type=\"default\">
-<image>https://screenshots.debian.net/screenshots/000/001/205/large.png</image>
-</screenshot>
-</screenshots>
-<url type=\"bugtracker\">https://forum.simutrans.com/index.php?board=8.0</url>
-<url type=\"homepage\">https://www.simutrans.com/</url>
-</component>
-")
-
-(define-public simutrans/pak128
+(define-public simutrans
;; Based off the Arch Linux package:
;; https://github.com/archlinux/svntogit-community/blob/packages/simutrans/trunk/PKGBUILD
;; I took the idea of a wrapper script from the Nix package:
;; https://github.com/NixOS/nixpkgs/blob/master/pkgs/games/simutrans/default.nix
(package
- (name "simutrans")
- (version "123.0.1")
- (source (origin
- (method url-fetch/zipbomb)
- (uri (let ((version/- (string-replace-substring version "." "-")))
- (string-append "mirror://sourceforge/simutrans/simutrans/"
- version/- "/simutrans-src-" version/- ".zip")))
- ;; Use `guix hash -H sha256 <file>'.
- (sha256 (base32 "0sgl2hrgjd2cyw3fbcvpq29dwf0w2sdlpp8ccic5bys1vv43iswd"))
- (patches (list simutrans-paths-patch))))
- (build-system gnu-build-system)
- (arguments
- `(#:make-flags
- '("VERBOSE=1" "OPTIMISE=1" "OSTYPE=linux" "BACKEND=sdl2" "MULTI_THREAD=1"
- "USE_ZSTD=1" "USE_FREETYPE=1" "USE_FLUIDSYNTH_MIDI=1")
- #:tests? #f ; tests don't work as SDL2 can't find a video device
- #:test-target "test" ; run "make test" for tests
- #:phases
- (modify-phases %standard-phases
- (replace 'bootstrap
- (lambda _
- (invoke "find" "." "-type" "f" "-exec" "dos2unix" "-q" "{}" ";")
- (substitute* "Makefile"
- (("\\\\#define") "#define"))))
- (replace 'configure
- (lambda _
- (copy-file "config.template" "config.default")))
+ (name "simutrans")
+ (version "123.0.1")
+ (source (origin
+ (method url-fetch/zipbomb)
+ (uri (let ((version/- (string-replace-substring version "." "-")))
+ (string-append "mirror://sourceforge/simutrans/simutrans/"
+ version/- "/simutrans-src-" version/- ".zip")))
+ ;; Use `guix hash -H sha256 <file>'.
+ (sha256 (base32 "0sgl2hrgjd2cyw3fbcvpq29dwf0w2sdlpp8ccic5bys1vv43iswd"))
+ (patches (list (local-file "files/simutrans-paths.patch")))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:make-flags
+ '("VERBOSE=1" "OPTIMISE=1" "OSTYPE=linux" "BACKEND=sdl2" "MULTI_THREAD=1"
+ "USE_ZSTD=1" "USE_FREETYPE=1" "USE_FLUIDSYNTH_MIDI=1")
+ #:tests? #f ; tests don't work as SDL2 can't find a video device
+ #:test-target "test" ; run "make test" for tests
+ #:phases
+ ,#~(modify-phases %standard-phases
+ (replace 'bootstrap
+ (lambda _
+ (apply invoke #+(file-append dos2unix "/bin/dos2unix")
+ "-q" (find-files "."))
+ (substitute* "Makefile"
+ (("\\\\#define") "#define"))))
+
+ (replace 'configure
+ (lambda _
+ (copy-file "config.template" "config.default")))
+
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ ;; Install "real" simutrans executable into libexec, as we need
+ ;; a wrapper script to be installed by `simutrans-pak-union'.
+ (with-directory-excursion "build/default"
+ (rename-file "sim" "simutrans")
+ (install-file "simutrans" (string-append out "/libexec")))
+
+ ;; Install game data bundled with simutrans (not the pak).
+ (let ((data (string-append out "/share/games/simutrans")))
+ (mkdir-p data)
+ (copy-recursively "simutrans" data))
+
+ ;; Install extra helper files.
+ (install-file "simutrans.svg"
+ (string-append out "/share/icons/hicolor/scalable/apps"))
+ (install-file #+(local-file "files/simutrans.desktop")
+ (string-append out "/share/applications"))
+ (install-file #+(local-file "files/simutrans.appdata.xml")
+ (string-append out "/share/metainfo"))))))))
+
+ (inputs (list `(,zstd "lib") freetype fluidsynth ; technically optional
+ zlib bzip2 libpng sdl2)) ; required
+ (native-inputs (list pkg-config)) ; build-time deps
+ (home-page "https://www.simutrans.com/")
+ (synopsis "Transportation simulation game")
+ (description "Simutrans is a freeware and open-source transportation
+simulator. Your goal is to establish a successful transport company.
+Transport passengers, mail and goods by rail, road, ship, and even air.
+Interconnect districts, cities, public buildings, industries and tourist
+attractions by building a transport network you always dreamed of.
+
+@strong{Warning:} This package by itself does not include any paksets.
+Install a @code{simutrans-with-pak*} package instead.")
+ (license (license:non-copyleft
+ "file://simutrans/license.txt"
+ "This is Simutrans' custom artistic license."))))
+
+;; See also: `sdl-union' in (gnu packages sdl).
+(define* (simutrans-pak-union name #:optional (paksets (list simutrans-pak128))
+ (base-game simutrans))
+ "Return union package called NAME which is a union of BASE-GAME and PAKSETS.
+If PAKSETS are not specified, simutrans is bundled with some default paksets."
+ (package
+ (name name)
+ (version (package-version base-game))
+ (source #f)
+ (build-system trivial-build-system)
+ (arguments
+ `(#:builder
+ ,(with-imported-modules
+ (source-module-closure
+ '((guix build union)
+ (guix build utils)))
+ #~(begin
+ (use-modules ((srfi srfi-26) #:select (cut))
+ (guix build union)
+ (guix build utils))
+
+ (union-build #$output (list #$base-game #$@paksets))
- (replace 'install
- (lambda* (#:key inputs outputs #:allow-other-keys)
- (let ((out (assoc-ref outputs "out")))
- ;; Install "real" simutrans executable into libexec, as we need a wrapper script.
- (with-directory-excursion "build/default"
- (rename-file "sim" "simutrans"))
- (install-file "build/default/simutrans"
- (string-append out "/libexec"))
;; Install wrapper script to pass the right workdir to simutrans.
- (mkdir-p (string-append out "/bin"))
- (with-output-to-file (string-append out "/bin/simutrans")
- (lambda ()
- (format #t "#! ~a/bin/guile --no-auto-compile\n!#\n~s\n"
- (assoc-ref inputs "guile")
- `(apply execl ,(string-append out "/libexec/simutrans") "simutrans"
- "-set_workdir" ,(string-append out "/share/games/simutrans")
- (cdr (command-line))))))
- (chmod (string-append out "/bin/simutrans") #o755)
+ (mkdir-p (string-append #$output "/bin"))
+ (call-with-output-file (string-append #$output "/bin/simutrans")
+ (cut format <> "#! ~a/bin/guile --no-auto-compile~%!#~%~s~%"
+ #$guile-3.0
+ `(apply execl ,(string-append #$output "/libexec/simutrans")
+ "simutrans" "-set_workdir"
+ ,(string-append #$output "/share/games/simutrans")
+ (cdr (command-line)))))
+ (chmod (string-append #$output "/bin/simutrans") #o755)))))
- ;; Install game data bundled with simutrans (not the pak).
- (mkdir-p (string-append out "/share/games/simutrans"))
- (copy-recursively
- "simutrans" (string-append out "/share/games/simutrans"))
- ;; Install a symlink to our pak, as simutrans needs all its data in one directory.
- (let ((pak (assoc-ref inputs "simutrans-pak128")))
- (symlink (string-append pak "/share/games/simutrans/pak128")
- (string-append out "/share/games/simutrans/pak128")))
+ (inputs (cons* guile-3.0 base-game paksets))
+ (synopsis "Union of Simutrans with paksets")
+ (description
+ "A union of the Simutrans game with some of its paksets. A union is
+required because Simutrans assumes that its paksets are installed in the same
+directory as assets from the base game, such as music files.")
+ (home-page (package-home-page base-game))
+ (license (map package-license (cons base-game paksets)))))
- ;; Install extra helper files.
- (install-file "simutrans.svg"
- (string-append out "/share/icons/hicolor/scalable/apps"))
- (mkdir-p (string-append out "/share/applications"))
- (with-output-to-file
- (string-append out "/share/applications/simutrans.desktop")
- (lambda () (display ,simutrans-desktop-entry)))
- (mkdir-p (string-append out "/share/metainfo"))
- (with-output-to-file
- (string-append out "/share/metainfo/simutrans.appdata.xml")
- (lambda () (display ,simutrans-appdata-xml)))))))))
+(define-public simutrans/pak128
+ (simutrans-pak-union "simutrans-with-pak128"
+ (list simutrans-pak128)))
- (inputs `(,zlib ,bzip2 ,libpng ,sdl2 ; these are required
- (,zstd "lib") ,freetype ,fluidsynth ; these are technically optional
- ,guile-3.0 ,simutrans-pak128))
- (native-inputs (list pkg-config findutils dos2unix)) ; build-time deps
- (home-page "https://www.simutrans.com/")
- (synopsis "Transportation simulation game")
- (description
- (string-append
- "Simutrans is a freeware and open-source transportation simulator. "
- "Your goal is to establish a successful transport company. "
- "Transport passengers, mail and goods by rail, road, ship, and even air. "
- "Interconnect districts, cities, public buildings, industries and tourist "
- "attractions by building a transport network you always dreamed of. "
- "This package comes bundled with simutrans-pak128."))
- (license (license:non-copyleft
- "file://simutrans/license.txt"
- "This is Simutrans' custom artistic license."))))