(define-module (tw packages games) #: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 compression) #:use-module (gnu packages fontutils) #:use-module (gnu packages guile) #:use-module (gnu packages image) #:use-module (gnu packages pkg-config) #:use-module (gnu packages sdl) #:use-module (gnu packages textutils) #:use-module (guix build utils) #:use-module (guix build-system copy) #:use-module (guix build-system gnu) #:use-module (guix build-system trivial) #: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))) (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 '. (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)) ;; Install wrapper script to pass the right workdir to simutrans. (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))))) (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))))) (define-public simutrans/pak128 (simutrans-pak-union "simutrans-with-pak128" (list simutrans-pak128))) ;; TODO: package Widelands 1.1 ;; https://github.com/widelands/widelands/releases/tag/v1.1