From b69edc44cc1cbbfaa85c5c6f067499409f46d51c Mon Sep 17 00:00:00 2001 From: Dee Anzorge Date: Sun, 3 Nov 2024 06:00:37 +0100 Subject: [PATCH 1/3] cataclysm-dda: clean up buildInputs * Add zlib. This was already present in tiles as an indirect dependency, but was missing from curses builds. * Remove ncurses from tiles builds. This ends up in closure anyway, but CDDA itself does not require it as a direct dependency for tiles builds. * use --replace-fail instead of --replace --- pkgs/games/cataclysm-dda/common.nix | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pkgs/games/cataclysm-dda/common.nix b/pkgs/games/cataclysm-dda/common.nix index 268f5d5256d2..74b4b7176bd1 100644 --- a/pkgs/games/cataclysm-dda/common.nix +++ b/pkgs/games/cataclysm-dda/common.nix @@ -1,5 +1,5 @@ { lib, stdenv, runtimeShell, pkg-config, gettext, ncurses, CoreFoundation -, tiles, SDL2, SDL2_image, SDL2_mixer, SDL2_ttf, freetype, Cocoa +, tiles, SDL2, SDL2_image, SDL2_mixer, SDL2_ttf, freetype, Cocoa, zlib , debug , useXdgDir }: @@ -7,15 +7,27 @@ let inherit (lib) optionals optionalString; - cursesDeps = [ gettext ncurses ] - ++ optionals stdenv.hostPlatform.isDarwin [ CoreFoundation ]; + commonDeps = [ + gettext + zlib + ] ++ optionals stdenv.hostPlatform.isDarwin [ CoreFoundation ]; - tilesDeps = [ SDL2 SDL2_image SDL2_mixer SDL2_ttf freetype ] + cursesDeps = commonDeps ++ [ ncurses ]; + + tilesDeps = + commonDeps + ++ [ + SDL2 + SDL2_image + SDL2_mixer + SDL2_ttf + freetype + ] ++ optionals stdenv.hostPlatform.isDarwin [ Cocoa ]; patchDesktopFile = '' substituteInPlace $out/share/applications/org.cataclysmdda.CataclysmDDA.desktop \ - --replace "Exec=cataclysm-tiles" "Exec=$out/bin/cataclysm-tiles" + --replace-fail "Exec=cataclysm-tiles" "Exec=$out/bin/cataclysm-tiles" ''; installMacOSAppLauncher = '' @@ -37,7 +49,7 @@ stdenv.mkDerivation { nativeBuildInputs = [ pkg-config ]; - buildInputs = cursesDeps ++ optionals tiles tilesDeps; + buildInputs = if tiles then tilesDeps else cursesDeps; postPatch = '' patchShebangs lang/compile_mo.sh From cd321ca9a4476d462b3f0bbe22719b56f51bbf90 Mon Sep 17 00:00:00 2001 From: Dee Anzorge Date: Sun, 24 Nov 2024 00:55:43 +0100 Subject: [PATCH 2/3] cataclysm-dda: 0.G -> 0.H Release announcement: https://cataclysmdda.org/releases/#0h-release-herbert Changelog: https://github.com/CleverRaven/Cataclysm-DDA/blob/0.H-RELEASE/data/changelog.txt --- pkgs/games/cataclysm-dda/common.nix | 9 ++-- pkgs/games/cataclysm-dda/default.nix | 10 ++--- pkgs/games/cataclysm-dda/git.nix | 8 ++-- pkgs/games/cataclysm-dda/glibc-2.39.diff | 28 ------------ .../games/cataclysm-dda/locale-path-git.patch | 17 ------- pkgs/games/cataclysm-dda/locale-path.patch | 9 ++-- pkgs/games/cataclysm-dda/stable.nix | 44 +++++-------------- 7 files changed, 25 insertions(+), 100 deletions(-) delete mode 100644 pkgs/games/cataclysm-dda/glibc-2.39.diff delete mode 100644 pkgs/games/cataclysm-dda/locale-path-git.patch diff --git a/pkgs/games/cataclysm-dda/common.nix b/pkgs/games/cataclysm-dda/common.nix index 74b4b7176bd1..3388db143852 100644 --- a/pkgs/games/cataclysm-dda/common.nix +++ b/pkgs/games/cataclysm-dda/common.nix @@ -1,5 +1,5 @@ -{ lib, stdenv, runtimeShell, pkg-config, gettext, ncurses, CoreFoundation -, tiles, SDL2, SDL2_image, SDL2_mixer, SDL2_ttf, freetype, Cocoa, zlib +{ lib, stdenv, runtimeShell, pkg-config, gettext, ncurses +, tiles, SDL2, SDL2_image, SDL2_mixer, SDL2_ttf, freetype, zlib , debug , useXdgDir }: @@ -10,7 +10,7 @@ let commonDeps = [ gettext zlib - ] ++ optionals stdenv.hostPlatform.isDarwin [ CoreFoundation ]; + ]; cursesDeps = commonDeps ++ [ ncurses ]; @@ -22,8 +22,7 @@ let SDL2_mixer SDL2_ttf freetype - ] - ++ optionals stdenv.hostPlatform.isDarwin [ Cocoa ]; + ]; patchDesktopFile = '' substituteInPlace $out/share/applications/org.cataclysmdda.CataclysmDDA.desktop \ diff --git a/pkgs/games/cataclysm-dda/default.nix b/pkgs/games/cataclysm-dda/default.nix index a42d4bf87f4d..3502d7c0fb54 100644 --- a/pkgs/games/cataclysm-dda/default.nix +++ b/pkgs/games/cataclysm-dda/default.nix @@ -1,20 +1,16 @@ -{ newScope, darwin }: +{ newScope }: let callPackage = newScope self; stable = rec { - tiles = callPackage ./stable.nix { - inherit (darwin.apple_sdk.frameworks) CoreFoundation Cocoa; - }; + tiles = callPackage ./stable.nix { }; curses = tiles.override { tiles = false; }; }; git = rec { - tiles = callPackage ./git.nix { - inherit (darwin.apple_sdk.frameworks) CoreFoundation Cocoa; - }; + tiles = callPackage ./git.nix { }; curses = tiles.override { tiles = false; }; }; diff --git a/pkgs/games/cataclysm-dda/git.nix b/pkgs/games/cataclysm-dda/git.nix index 495d5f97fb09..0904ac06b27b 100644 --- a/pkgs/games/cataclysm-dda/git.nix +++ b/pkgs/games/cataclysm-dda/git.nix @@ -1,5 +1,5 @@ -{ lib, callPackage, CoreFoundation, fetchFromGitHub, fetchpatch, pkgs, wrapCDDA, attachPkgs -, tiles ? true, Cocoa +{ lib, callPackage, fetchFromGitHub, fetchpatch, pkgs, wrapCDDA, attachPkgs +, tiles ? true , debug ? false , useXdgDir ? false , version ? "2024-07-28" @@ -9,7 +9,7 @@ let common = callPackage ./common.nix { - inherit CoreFoundation tiles Cocoa debug useXdgDir; + inherit tiles debug useXdgDir; }; self = common.overrideAttrs (common: rec { @@ -24,7 +24,7 @@ let patches = [ # Unconditionally look for translation files in $out/share/locale - ./locale-path-git.patch + ./locale-path.patch ]; makeFlags = common.makeFlags ++ [ diff --git a/pkgs/games/cataclysm-dda/glibc-2.39.diff b/pkgs/games/cataclysm-dda/glibc-2.39.diff deleted file mode 100644 index edc79ce76d79..000000000000 --- a/pkgs/games/cataclysm-dda/glibc-2.39.diff +++ /dev/null @@ -1,28 +0,0 @@ -diff --git a/src/debug.cpp b/src/debug.cpp -index fa63a3b..1e8f554 100644 ---- a/src/debug.cpp -+++ b/src/debug.cpp -@@ -1494,6 +1494,14 @@ std::string game_info::operating_system() - } - - #if !defined(__CYGWIN__) && !defined (__ANDROID__) && ( defined (__linux__) || defined(unix) || defined(__unix__) || defined(__unix) || ( defined(__APPLE__) && defined(__MACH__) ) || defined(BSD) ) // linux; unix; MacOs; BSD -+ // -+class FILEDeleter -+{ -+ public: -+ void operator()( FILE *f ) const noexcept { -+ pclose( f ); -+ } -+}; - /** Execute a command with the shell by using `popen()`. - * @param command The full command to execute. - * @note The output buffer is limited to 512 characters. -@@ -1504,7 +1512,7 @@ static std::string shell_exec( const std::string &command ) - std::vector buffer( 512 ); - std::string output; - try { -- std::unique_ptr pipe( popen( command.c_str(), "r" ), pclose ); -+ std::unique_ptr pipe( popen( command.c_str(), "r" ) ); - if( pipe ) { - while( fgets( buffer.data(), buffer.size(), pipe.get() ) != nullptr ) { - output += buffer.data(); diff --git a/pkgs/games/cataclysm-dda/locale-path-git.patch b/pkgs/games/cataclysm-dda/locale-path-git.patch deleted file mode 100644 index 8f18b0ffb71e..000000000000 --- a/pkgs/games/cataclysm-dda/locale-path-git.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/src/translations.cpp b/src/translations.cpp ---- a/src/translations.cpp -+++ b/src/translations.cpp -@@ -52,13 +52,11 @@ std::string locale_dir() - #define CATA_IS_ON_BSD - #endif - --#if !defined(__ANDROID__) && ((defined(__linux__) || defined(CATA_IS_ON_BSD) || (defined(MACOSX) && !defined(TILES)))) - if( !PATH_INFO::base_path().empty() ) { - loc_dir = PATH_INFO::base_path() + "share/locale"; - } else { - loc_dir = PATH_INFO::langdir(); - } --#endif - #endif // LOCALIZE - return loc_dir; - } diff --git a/pkgs/games/cataclysm-dda/locale-path.patch b/pkgs/games/cataclysm-dda/locale-path.patch index 03f103a548fd..8f18b0ffb71e 100644 --- a/pkgs/games/cataclysm-dda/locale-path.patch +++ b/pkgs/games/cataclysm-dda/locale-path.patch @@ -1,12 +1,11 @@ diff --git a/src/translations.cpp b/src/translations.cpp -index 76bdfd0..6dd6109 100644 --- a/src/translations.cpp +++ b/src/translations.cpp -@@ -61,13 +61,11 @@ std::string locale_dir() - #define BSD +@@ -52,13 +52,11 @@ std::string locale_dir() + #define CATA_IS_ON_BSD #endif - --#if !defined(__ANDROID__) && ((defined(__linux__) || defined(BSD) || (defined(MACOSX) && !defined(TILES)))) + +-#if !defined(__ANDROID__) && ((defined(__linux__) || defined(CATA_IS_ON_BSD) || (defined(MACOSX) && !defined(TILES)))) if( !PATH_INFO::base_path().empty() ) { loc_dir = PATH_INFO::base_path() + "share/locale"; } else { diff --git a/pkgs/games/cataclysm-dda/stable.nix b/pkgs/games/cataclysm-dda/stable.nix index 5c3ccb4bf287..105d30346dbd 100644 --- a/pkgs/games/cataclysm-dda/stable.nix +++ b/pkgs/games/cataclysm-dda/stable.nix @@ -1,66 +1,42 @@ { lib , callPackage -, CoreFoundation , fetchFromGitHub , fetchpatch , pkgs , wrapCDDA , attachPkgs , tiles ? true -, Cocoa , debug ? false , useXdgDir ? false }: let common = callPackage ./common.nix { - inherit CoreFoundation tiles Cocoa debug useXdgDir; + inherit tiles debug useXdgDir; }; self = common.overrideAttrs (common: rec { - version = "0.G"; + version = "0.H"; src = fetchFromGitHub { owner = "CleverRaven"; repo = "Cataclysm-DDA"; - rev = version; - sha256 = "sha256-Hda0dVVHNeZ8MV5CaCbSpdOCG2iqQEEmXdh16vwIBXk="; + tag = "${version}-RELEASE"; + sha256 = "sha256-ZCD5qgqYSX7sS+Tc1oNYq9soYwNUUuWamY2uXfLjGoY="; }; patches = [ + # fix compilation of the vendored flatbuffers under gcc14 + (fetchpatch { + name = "fix-flatbuffers-with-gcc14"; + url = "https://github.com/CleverRaven/Cataclysm-DDA/commit/1400b1018ff37196bd24ba4365bd50beb571ac14.patch"; + hash = "sha256-H0jct6lSQxu48eOZ4f8HICxo89qX49Ksw+Xwwtp7iFM="; + }) # Unconditionally look for translation files in $out/share/locale ./locale-path.patch - # Fixes for failing build with GCC 13, remove on updating next release after 0.G - (fetchpatch { - url = "https://sources.debian.org/data/main/c/cataclysm-dda/0.G-4/debian/patches/gcc13-dangling-reference-warning.patch"; - hash = "sha256-9nPbyz49IYBOVHqr7jzCIyS8z/SQgpK4EjEz1fruIPE="; - }) - (fetchpatch { - url = "https://sources.debian.org/data/main/c/cataclysm-dda/0.G-4/debian/patches/gcc13-cstdint.patch"; - hash = "sha256-8IBW2OzAHVgEJZoViQ490n37sl31hA55ePuqDL/lil0="; - }) - (fetchpatch { - url = "https://sources.debian.org/data/main/c/cataclysm-dda/0.G-4/debian/patches/gcc13-keyword-requires.patch"; - hash = "sha256-8yvHh0YKC7AC/qzia7AZAfMewMC0RiSepMXpOkMXRd8="; - }) - # Fix build w/ glibc-2.39 - # From https://github.com/BrettDong/Cataclysm-DDA/commit/9b206e2dc969ad79345596e03c3980bd155d2f48 - ./glibc-2.39.diff - ]; - - makeFlags = common.makeFlags ++ [ - # Makefile declares version as 0.F, with no minor release number - "VERSION=${version}" - ]; - - env.NIX_CFLAGS_COMPILE = toString [ - # Needed with GCC 12 - "-Wno-error=array-bounds" ]; meta = common.meta // { - maintainers = with lib.maintainers; - common.meta.maintainers; changelog = "https://github.com/CleverRaven/Cataclysm-DDA/blob/${version}/data/changelog.txt"; }; }); From c4a6fba1c9aef037c076a3d294ae1b1fd241b63b Mon Sep 17 00:00:00 2001 From: Dee Anzorge Date: Tue, 5 Nov 2024 00:20:53 +0100 Subject: [PATCH 3/3] cataclysm-dda-git: 2024-07-28 -> 2024-12-11 --- pkgs/games/cataclysm-dda/git.nix | 8 ++++---- pkgs/games/cataclysm-dda/locale-path-git.patch | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 pkgs/games/cataclysm-dda/locale-path-git.patch diff --git a/pkgs/games/cataclysm-dda/git.nix b/pkgs/games/cataclysm-dda/git.nix index 0904ac06b27b..cc79728f2961 100644 --- a/pkgs/games/cataclysm-dda/git.nix +++ b/pkgs/games/cataclysm-dda/git.nix @@ -2,9 +2,9 @@ , tiles ? true , debug ? false , useXdgDir ? false -, version ? "2024-07-28" -, rev ? "bfeb1fffc4179fed242a042f24b1c97f6cfaff3d" -, sha256 ? "sha256-IodXEA+pWfDdR9huRXieP3+J3WZJO19C8PUPT18dFBw=" +, version ? "2024-12-11" +, rev ? "b871679a2d54dbc6bf3e6566033fadd2dc651592" +, sha256 ? "sha256-t9R0QPky7zvjgGMq4kV8DdQFToJ/qngbJCw+8FlQztM=" }: let @@ -24,7 +24,7 @@ let patches = [ # Unconditionally look for translation files in $out/share/locale - ./locale-path.patch + ./locale-path-git.patch ]; makeFlags = common.makeFlags ++ [ diff --git a/pkgs/games/cataclysm-dda/locale-path-git.patch b/pkgs/games/cataclysm-dda/locale-path-git.patch new file mode 100644 index 000000000000..480f7107946e --- /dev/null +++ b/pkgs/games/cataclysm-dda/locale-path-git.patch @@ -0,0 +1,17 @@ +diff --git a/src/translations.cpp b/src/translations.cpp +--- a/src/translations.cpp ++++ b/src/translations.cpp +@@ -52,13 +52,11 @@ std::string locale_dir() + #define CATA_IS_ON_BSD + #endif + +-#if !defined(__ANDROID__) && ((defined(__linux__) || defined(CATA_IS_ON_BSD) || (defined(MACOSX) && !defined(TILES)))) + if( !PATH_INFO::base_path().get_logical_root_path().empty() ) { + loc_dir = ( PATH_INFO::base_path() / "share" / "locale" ).generic_u8string(); + } else { + loc_dir = PATH_INFO::langdir(); + } +-#endif + #endif // LOCALIZE + return loc_dir; + }