From cdfabd6440d380c75b8501d38be357475db4b87d Mon Sep 17 00:00:00 2001 From: Tom van Dijk <18gatenmaker6@gmail.com> Date: Thu, 23 Oct 2025 13:37:12 +0200 Subject: [PATCH 1/9] tome4: remove references to pname --- pkgs/by-name/to/tome4/package.nix | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkgs/by-name/to/tome4/package.nix b/pkgs/by-name/to/tome4/package.nix index c9c23e185156..2cad28ec24a9 100644 --- a/pkgs/by-name/to/tome4/package.nix +++ b/pkgs/by-name/to/tome4/package.nix @@ -25,17 +25,17 @@ stdenv.mkDerivation rec { }; desktop = makeDesktopItem { - desktopName = pname; - name = pname; - exec = "@out@/bin/${pname}"; - icon = pname; + desktopName = "tome4"; + name = "Tales of Maj'Eyal"; + exec = "@out@/bin/tome4"; + icon = "tome4"; comment = "An open-source, single-player, role-playing roguelike game set in the world of Eyal."; type = "Application"; categories = [ "Game" "RolePlaying" ]; - genericName = pname; + genericName = "2D roguelike RPG"; }; prePatch = '' @@ -74,21 +74,21 @@ stdenv.mkDerivation rec { installPhase = '' runHook preInstall - dir=$out/share/${pname} + dir=$out/share/tome4 install -Dm755 t-engine $dir/t-engine cp -r bootstrap game $dir - makeWrapper $dir/t-engine $out/bin/${pname} \ + makeWrapper $dir/t-engine $out/bin/tome4 \ --chdir "$dir" - install -Dm755 ${desktop}/share/applications/${pname}.desktop $out/share/applications/${pname}.desktop - substituteInPlace $out/share/applications/${pname}.desktop \ + install -Dm755 ${desktop}/share/applications/tome4.desktop $out/share/applications/tome4.desktop + substituteInPlace $out/share/applications/tome4.desktop \ --subst-var out unzip -oj -qq game/engines/te4-${version}.teae data/gfx/te4-icon.png - install -Dm644 te4-icon.png $out/share/icons/hicolor/64x64/${pname}.png + install -Dm644 te4-icon.png $out/share/icons/hicolor/64x64/tome4.png - install -Dm644 -t $out/share/doc/${pname} CONTRIBUTING COPYING COPYING-MEDIA CREDITS + install -Dm644 -t $out/share/doc/tome4 CONTRIBUTING COPYING COPYING-MEDIA CREDITS runHook postInstall ''; From 1d41c1d76c40bf0549a7ece53dd81e9fce227af6 Mon Sep 17 00:00:00 2001 From: Tom van Dijk <18gatenmaker6@gmail.com> Date: Thu, 23 Oct 2025 13:37:52 +0200 Subject: [PATCH 2/9] tome4: rec -> finalAttrs --- pkgs/by-name/to/tome4/package.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/to/tome4/package.nix b/pkgs/by-name/to/tome4/package.nix index 2cad28ec24a9..a9693533dac6 100644 --- a/pkgs/by-name/to/tome4/package.nix +++ b/pkgs/by-name/to/tome4/package.nix @@ -15,12 +15,12 @@ SDL2_ttf, }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "tome4"; version = "1.7.6"; src = fetchurl { - url = "https://te4.org/dl/t-engine/t-engine4-src-${version}.tar.bz2"; + url = "https://te4.org/dl/t-engine/t-engine4-src-${finalAttrs.version}.tar.bz2"; sha256 = "sha256-mJ3qAIA/jNyt4CT0ZH1IC7GsDUN8JUKSwHVJwnKkaAw="; }; @@ -81,11 +81,11 @@ stdenv.mkDerivation rec { makeWrapper $dir/t-engine $out/bin/tome4 \ --chdir "$dir" - install -Dm755 ${desktop}/share/applications/tome4.desktop $out/share/applications/tome4.desktop + install -Dm755 ${finalAttrs.desktop}/share/applications/tome4.desktop $out/share/applications/tome4.desktop substituteInPlace $out/share/applications/tome4.desktop \ --subst-var out - unzip -oj -qq game/engines/te4-${version}.teae data/gfx/te4-icon.png + unzip -oj -qq game/engines/te4-${finalAttrs.version}.teae data/gfx/te4-icon.png install -Dm644 te4-icon.png $out/share/icons/hicolor/64x64/tome4.png install -Dm644 -t $out/share/doc/tome4 CONTRIBUTING COPYING COPYING-MEDIA CREDITS @@ -104,4 +104,4 @@ stdenv.mkDerivation rec { "x86_64-linux" ]; }; -} +}) From e1d465f7d52140de1ad1228cfce374b3d5a0a679 Mon Sep 17 00:00:00 2001 From: Tom van Dijk <18gatenmaker6@gmail.com> Date: Thu, 23 Oct 2025 13:38:29 +0200 Subject: [PATCH 3/9] tome4: remove `with lib;` --- pkgs/by-name/to/tome4/package.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/to/tome4/package.nix b/pkgs/by-name/to/tome4/package.nix index a9693533dac6..956949657f01 100644 --- a/pkgs/by-name/to/tome4/package.nix +++ b/pkgs/by-name/to/tome4/package.nix @@ -93,12 +93,12 @@ stdenv.mkDerivation (finalAttrs: { runHook postInstall ''; - meta = with lib; { + meta = { description = "Tales of Maj'eyal (rogue-like game)"; mainProgram = "tome4"; homepage = "https://te4.org/"; - license = licenses.gpl3; - maintainers = with maintainers; [ peterhoeg ]; + license = lib.licenses.gpl3; + maintainers = with lib.maintainers; [ peterhoeg ]; platforms = [ "i686-linux" "x86_64-linux" From 95cd63bebc6566b031813bcf4518a588948b5c02 Mon Sep 17 00:00:00 2001 From: Tom van Dijk <18gatenmaker6@gmail.com> Date: Thu, 23 Oct 2025 13:39:09 +0200 Subject: [PATCH 4/9] tome4: use copyDesktopItems --- pkgs/by-name/to/tome4/package.nix | 41 ++++++++++++++----------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/pkgs/by-name/to/tome4/package.nix b/pkgs/by-name/to/tome4/package.nix index 956949657f01..770e5974768b 100644 --- a/pkgs/by-name/to/tome4/package.nix +++ b/pkgs/by-name/to/tome4/package.nix @@ -2,10 +2,10 @@ lib, stdenv, fetchurl, + copyDesktopItems, makeDesktopItem, makeWrapper, premake4, - unzip, openal, libpng, libvorbis, @@ -24,28 +24,14 @@ stdenv.mkDerivation (finalAttrs: { sha256 = "sha256-mJ3qAIA/jNyt4CT0ZH1IC7GsDUN8JUKSwHVJwnKkaAw="; }; - desktop = makeDesktopItem { - desktopName = "tome4"; - name = "Tales of Maj'Eyal"; - exec = "@out@/bin/tome4"; - icon = "tome4"; - comment = "An open-source, single-player, role-playing roguelike game set in the world of Eyal."; - type = "Application"; - categories = [ - "Game" - "RolePlaying" - ]; - genericName = "2D roguelike RPG"; - }; - prePatch = '' # http://forums.te4.org/viewtopic.php?f=42&t=49478&view=next#p234354 sed -i 's|#include ||' src/tgl.h ''; nativeBuildInputs = [ + copyDesktopItems makeWrapper - unzip premake4 ]; @@ -68,6 +54,22 @@ stdenv.mkDerivation (finalAttrs: { makeFlags = [ "config=release" ]; + desktopItems = [ + (makeDesktopItem { + desktopName = "Tales of Maj'Eyal"; + name = "tome4"; + exec = "tome4"; + icon = "te4-icon"; + comment = "An open-source, single-player, role-playing roguelike game set in the world of Eyal."; + type = "Application"; + categories = [ + "Game" + "RolePlaying" + ]; + genericName = "2D roguelike RPG"; + }) + ]; + # The wrapper needs to cd into the correct directory as tome4's detection of # the game asset root directory is faulty. @@ -81,12 +83,7 @@ stdenv.mkDerivation (finalAttrs: { makeWrapper $dir/t-engine $out/bin/tome4 \ --chdir "$dir" - install -Dm755 ${finalAttrs.desktop}/share/applications/tome4.desktop $out/share/applications/tome4.desktop - substituteInPlace $out/share/applications/tome4.desktop \ - --subst-var out - - unzip -oj -qq game/engines/te4-${finalAttrs.version}.teae data/gfx/te4-icon.png - install -Dm644 te4-icon.png $out/share/icons/hicolor/64x64/tome4.png + install -Dm644 game/engines/default/data/gfx/te4-icon.png -t $out/share/icons/hicolor/64x64 install -Dm644 -t $out/share/doc/tome4 CONTRIBUTING COPYING COPYING-MEDIA CREDITS From 25454ff52fa4c9984e3b69dbdaca8b17cd7760da Mon Sep 17 00:00:00 2001 From: Tom van Dijk <18gatenmaker6@gmail.com> Date: Thu, 23 Oct 2025 13:41:55 +0200 Subject: [PATCH 5/9] tome4: use substituteInPlace instead of sed --- pkgs/by-name/to/tome4/package.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/to/tome4/package.nix b/pkgs/by-name/to/tome4/package.nix index 770e5974768b..777ee07186e4 100644 --- a/pkgs/by-name/to/tome4/package.nix +++ b/pkgs/by-name/to/tome4/package.nix @@ -26,7 +26,8 @@ stdenv.mkDerivation (finalAttrs: { prePatch = '' # http://forums.te4.org/viewtopic.php?f=42&t=49478&view=next#p234354 - sed -i 's|#include ||' src/tgl.h + substituteInPlace src/tgl.h \ + --replace-fail "#include " "" ''; nativeBuildInputs = [ From 6ef6514633857d4195db067d9da29fbc4ff7f7f9 Mon Sep 17 00:00:00 2001 From: Tom van Dijk <18gatenmaker6@gmail.com> Date: Thu, 23 Oct 2025 13:50:28 +0200 Subject: [PATCH 6/9] tome4: sha256 -> hash --- pkgs/by-name/to/tome4/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/by-name/to/tome4/package.nix b/pkgs/by-name/to/tome4/package.nix index 777ee07186e4..82691a86a2ad 100644 --- a/pkgs/by-name/to/tome4/package.nix +++ b/pkgs/by-name/to/tome4/package.nix @@ -21,7 +21,7 @@ stdenv.mkDerivation (finalAttrs: { src = fetchurl { url = "https://te4.org/dl/t-engine/t-engine4-src-${finalAttrs.version}.tar.bz2"; - sha256 = "sha256-mJ3qAIA/jNyt4CT0ZH1IC7GsDUN8JUKSwHVJwnKkaAw="; + hash = "sha256-mJ3qAIA/jNyt4CT0ZH1IC7GsDUN8JUKSwHVJwnKkaAw="; }; prePatch = '' From 7389da9a751bb6794b3ef1a46298b75e9bc07a95 Mon Sep 17 00:00:00 2001 From: Tom van Dijk <18gatenmaker6@gmail.com> Date: Thu, 23 Oct 2025 14:13:15 +0200 Subject: [PATCH 7/9] tome4: build from official sources --- pkgs/by-name/to/tome4/package.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/to/tome4/package.nix b/pkgs/by-name/to/tome4/package.nix index 82691a86a2ad..54111b960562 100644 --- a/pkgs/by-name/to/tome4/package.nix +++ b/pkgs/by-name/to/tome4/package.nix @@ -1,7 +1,7 @@ { lib, stdenv, - fetchurl, + fetchFromGitLab, copyDesktopItems, makeDesktopItem, makeWrapper, @@ -19,9 +19,13 @@ stdenv.mkDerivation (finalAttrs: { pname = "tome4"; version = "1.7.6"; - src = fetchurl { - url = "https://te4.org/dl/t-engine/t-engine4-src-${finalAttrs.version}.tar.bz2"; - hash = "sha256-mJ3qAIA/jNyt4CT0ZH1IC7GsDUN8JUKSwHVJwnKkaAw="; + # Official source according to https://te4.org/wiki/How_to_compile + src = fetchFromGitLab { + domain = "git.net-core.org"; + owner = "tome"; + repo = "t-engine4"; + tag = "tome-${finalAttrs.version}"; + hash = "sha256-v0YPbmaOqKYgFkOe/X0FCirucrMo2UGAyhZ7MFj+nsU="; }; prePatch = '' From 38f2134339e766a2411a79c05153ea089240c46e Mon Sep 17 00:00:00 2001 From: Tom van Dijk <18gatenmaker6@gmail.com> Date: Thu, 23 Oct 2025 14:45:36 +0200 Subject: [PATCH 8/9] tome4: fix build --- .../to/tome4/0001-web-missing-include.patch | 24 +++++++ .../to/tome4/0002-zlib-missing-include.patch | 24 +++++++ .../0003-incompatible-pointer-types.patch | 71 +++++++++++++++++++ pkgs/by-name/to/tome4/package.nix | 40 +++++++++-- 4 files changed, 154 insertions(+), 5 deletions(-) create mode 100644 pkgs/by-name/to/tome4/0001-web-missing-include.patch create mode 100644 pkgs/by-name/to/tome4/0002-zlib-missing-include.patch create mode 100644 pkgs/by-name/to/tome4/0003-incompatible-pointer-types.patch diff --git a/pkgs/by-name/to/tome4/0001-web-missing-include.patch b/pkgs/by-name/to/tome4/0001-web-missing-include.patch new file mode 100644 index 000000000000..e23aa77c1ca2 --- /dev/null +++ b/pkgs/by-name/to/tome4/0001-web-missing-include.patch @@ -0,0 +1,24 @@ +From e0c17a8665250b3e3e7f4938f7b256ff50b78fc8 Mon Sep 17 00:00:00 2001 +From: Tom van Dijk <18gatenmaker6@gmail.com> +Date: Thu, 23 Oct 2025 15:01:01 +0200 +Subject: [PATCH 1/3] web missing include + +--- + src/web.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/web.c b/src/web.c +index f12eebb..940aaf9 100644 +--- a/src/web.c ++++ b/src/web.c +@@ -32,6 +32,7 @@ + #include "te4web.h" + #include "web-external.h" + #include "lua_externs.h" ++#include + + /* + * Grab web browser methods -- availabe only here +-- +2.51.0 + diff --git a/pkgs/by-name/to/tome4/0002-zlib-missing-include.patch b/pkgs/by-name/to/tome4/0002-zlib-missing-include.patch new file mode 100644 index 000000000000..d6fb92441f2b --- /dev/null +++ b/pkgs/by-name/to/tome4/0002-zlib-missing-include.patch @@ -0,0 +1,24 @@ +From a14890a8a7080c73cac10ff31365833b179c0464 Mon Sep 17 00:00:00 2001 +From: Tom van Dijk <18gatenmaker6@gmail.com> +Date: Thu, 23 Oct 2025 15:45:03 +0200 +Subject: [PATCH 2/3] zlib missing include + +--- + src/zlib/gzguts.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/zlib/gzguts.h b/src/zlib/gzguts.h +index 990a4d2..7c89751 100644 +--- a/src/zlib/gzguts.h ++++ b/src/zlib/gzguts.h +@@ -21,6 +21,7 @@ + #include + #include "zlib.h" + #ifdef STDC ++# include + # include + # include + # include +-- +2.51.0 + diff --git a/pkgs/by-name/to/tome4/0003-incompatible-pointer-types.patch b/pkgs/by-name/to/tome4/0003-incompatible-pointer-types.patch new file mode 100644 index 000000000000..f2e1b36b34de --- /dev/null +++ b/pkgs/by-name/to/tome4/0003-incompatible-pointer-types.patch @@ -0,0 +1,71 @@ +From ed9f9819c3a0d6b8e92f66aafa6324eb4b310282 Mon Sep 17 00:00:00 2001 +From: Tom van Dijk <18gatenmaker6@gmail.com> +Date: Thu, 23 Oct 2025 15:53:06 +0200 +Subject: [PATCH 3/3] incompatible pointer types + +--- + src/display_sdl.c | 2 +- + src/physfs/archivers/bind_physfs.c | 2 +- + src/physfs/physfs.c | 3 ++- + src/tgl.h | 2 +- + 4 files changed, 5 insertions(+), 4 deletions(-) + +diff --git a/src/display_sdl.c b/src/display_sdl.c +index 61b2f0e..c533c8b 100644 +--- a/src/display_sdl.c ++++ b/src/display_sdl.c +@@ -78,5 +78,5 @@ GLuint gl_c_shader = 0; + int nb_draws = 0; + int gl_c_vertices_nb = 0, gl_c_texcoords_nb = 0, gl_c_colors_nb = 0; + GLfloat *gl_c_vertices_ptr = NULL; +-GLfloat *gl_c_texcoords_ptr = NULL; ++void *gl_c_texcoords_ptr = NULL; + GLfloat *gl_c_colors_ptr = NULL; +diff --git a/src/physfs/archivers/bind_physfs.c b/src/physfs/archivers/bind_physfs.c +index d02d323..c0d77c1 100644 +--- a/src/physfs/archivers/bind_physfs.c ++++ b/src/physfs/archivers/bind_physfs.c +@@ -222,7 +222,7 @@ static fvoid *doOpen(dvoid *opaque, const char *name, + + static fvoid *BIND_PHYSFS_openRead(dvoid *opaque, const char *fnm, int *exist) + { +- return(doOpen(opaque, fnm, PHYSFS_openRead, exist)); ++ return(doOpen(opaque, fnm, (void * (*)(const char *)) PHYSFS_openRead, exist)); + } /* BIND_PHYSFS_openRead */ + + +diff --git a/src/physfs/physfs.c b/src/physfs/physfs.c +index 03eb86d..32e2c91 100644 +--- a/src/physfs/physfs.c ++++ b/src/physfs/physfs.c +@@ -68,12 +68,13 @@ extern const PHYSFS_Archiver __PHYSFS_Archiver_MVL; + extern const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_WAD; + extern const PHYSFS_Archiver __PHYSFS_Archiver_WAD; + extern const PHYSFS_Archiver __PHYSFS_Archiver_DIR; ++extern const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_BIND_PHYSFS; + extern const PHYSFS_Archiver __PHYSFS_Archiver_BIND_PHYSFS; + + + static const PHYSFS_ArchiveInfo *supported_types[] = + { +- &__PHYSFS_Archiver_BIND_PHYSFS, ++ &__PHYSFS_ArchiveInfo_BIND_PHYSFS, + #if (defined PHYSFS_SUPPORTS_ZIP) + &__PHYSFS_ArchiveInfo_SUBZIP, + &__PHYSFS_ArchiveInfo_ZIP, +diff --git a/src/tgl.h b/src/tgl.h +index e2ec026..f905033 100644 +--- a/src/tgl.h ++++ b/src/tgl.h +@@ -71,7 +71,7 @@ extern int nb_draws; + + extern int gl_c_vertices_nb, gl_c_texcoords_nb, gl_c_colors_nb; + extern GLfloat *gl_c_vertices_ptr; +-extern GLfloat *gl_c_texcoords_ptr; ++extern void *gl_c_texcoords_ptr; + extern GLfloat *gl_c_colors_ptr; + #define glVertexPointer(nb, t, v, p) \ + { \ +-- +2.51.0 + diff --git a/pkgs/by-name/to/tome4/package.nix b/pkgs/by-name/to/tome4/package.nix index 54111b960562..0d7b218b44ce 100644 --- a/pkgs/by-name/to/tome4/package.nix +++ b/pkgs/by-name/to/tome4/package.nix @@ -2,6 +2,7 @@ lib, stdenv, fetchFromGitLab, + fetchpatch2, copyDesktopItems, makeDesktopItem, makeWrapper, @@ -13,8 +14,17 @@ SDL2, SDL2_image, SDL2_ttf, + xorg, }: +let + sdlInputs = [ + SDL2 + SDL2_ttf + SDL2_image + ]; +in + stdenv.mkDerivation (finalAttrs: { pname = "tome4"; version = "1.7.6"; @@ -34,6 +44,19 @@ stdenv.mkDerivation (finalAttrs: { --replace-fail "#include " "" ''; + patches = [ + # https://forums.te4.org/viewtopic.php?f=69&t=39859&p=168681&hilit=luaopen_shaders#p168681 + (fetchpatch2 { + url = "https://gist.githubusercontent.com/hasufell/cb3b10f834e891d90f83/raw/cb4adda13868f6b94585575db4f8df70877ae45a/tome4-1.1.3-fix-implicit-declaration.patch"; + hash = "sha256-g47N/bi2/DDKqaEkfTaGp9ItS57QVnObzMDWXqrCjWE="; + }) + # unistd required for execv + ./0001-web-missing-include.patch + # unistd required for read and close + ./0002-zlib-missing-include.patch + ./0003-incompatible-pointer-types.patch + ]; + nativeBuildInputs = [ copyDesktopItems makeWrapper @@ -47,15 +70,22 @@ stdenv.mkDerivation (finalAttrs: { openal libpng libvorbis - SDL2 - SDL2_ttf - SDL2_image - ]; + xorg.libX11 + xorg.xorgproto + ] + ++ sdlInputs; # disable parallel building as it caused sporadic build failures enableParallelBuilding = false; - env.NIX_CFLAGS_COMPILE = "-I${lib.getInclude SDL2}/include/SDL2 -I${SDL2_image}/include/SDL2 -I${SDL2_ttf}/include/SDL2"; + env = { + NIX_CFLAGS_COMPILE = + lib.concatMapStringsSep " " (i: "-I${lib.getInclude i}/include/SDL2") sdlInputs + + " " + + lib.concatMapStringsSep " " (i: "-I${lib.getInclude i}") finalAttrs.buildInputs; + + NIX_CFLAGS_LINK = lib.concatMapStringsSep " " (i: "-L${lib.getLib i}/lib") finalAttrs.buildInputs; + }; makeFlags = [ "config=release" ]; From 0ba4d0e96e2358ea1db4737ff8591cba314a574e Mon Sep 17 00:00:00 2001 From: Tom van Dijk <18gatenmaker6@gmail.com> Date: Thu, 23 Oct 2025 16:35:15 +0200 Subject: [PATCH 9/9] tome4: add update script --- pkgs/by-name/to/tome4/package.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/by-name/to/tome4/package.nix b/pkgs/by-name/to/tome4/package.nix index 0d7b218b44ce..d74852014c8e 100644 --- a/pkgs/by-name/to/tome4/package.nix +++ b/pkgs/by-name/to/tome4/package.nix @@ -15,6 +15,7 @@ SDL2_image, SDL2_ttf, xorg, + nix-update-script, }: let @@ -125,6 +126,13 @@ stdenv.mkDerivation (finalAttrs: { runHook postInstall ''; + passthru.updateScript = nix-update-script { + extraArgs = [ + "--version-regex" + "tome-(.*)" + ]; + }; + meta = { description = "Tales of Maj'eyal (rogue-like game)"; mainProgram = "tome4";