From 54f0a727c312b82e5d1c25ca81b62344bbb56e10 Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Fri, 30 Dec 2022 20:52:54 +0100 Subject: Import custom packages Also, import package modules instead of using `specifications->packages'. --- tw/packages/games.scm | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 tw/packages/games.scm (limited to 'tw/packages/games.scm') diff --git a/tw/packages/games.scm b/tw/packages/games.scm new file mode 100644 index 00000000..ca6d6308 --- /dev/null +++ b/tw/packages/games.scm @@ -0,0 +1,198 @@ +(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 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) + #: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 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 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 "\ + + +com.simutrans.simutrans +simutrans.desktop +Simutrans +Transportation simulator +CC0-1.0 +Artistic-1.0 + +

Simutrans is a free transportation simulator: the player operates a transportation \ +company and has to transport goods and passengers between factories and different cities.

+
+ + +https://screenshots.debian.net/screenshots/000/001/205/large.png + + +https://forum.simutrans.com/index.php?board=8.0 +https://www.simutrans.com/ +
+") + +(define-public simutrans/pak128 + ;; 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 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"))) + + (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) + + ;; 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"))) + + ;; 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))))))))) + + (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 + (string-append + "https://raw.githubusercontent.com/aburch/simutrans/" + "8593f5b1248d03f907a149f7abc41ae6512009e1/simutrans/license.txt") + "This is Simutrans' custom artistic license.")))) -- cgit v1.2.3