cataclysm-dda{,-git}: apply locale patch dynamically

Each time src/translations.cpp is modified, we have to update the locale
patch. Using sed to patch dynamically should be handy.

+5 -45
+5
pkgs/games/cataclysm-dda/common.nix
··· 21 21 22 22 postPatch = '' 23 23 patchShebangs . 24 + 25 + # Locale patch required for Darwin builds, see: 26 + # https://github.com/NixOS/nixpkgs/pull/74064#issuecomment-560083970 27 + sed -i src/translations.cpp \ 28 + -e 's@#elif (defined(__linux__) || (defined(MACOSX) && !defined(TILES)))@#elif 1@' 24 29 ''; 25 30 26 31 makeFlags = [
-2
pkgs/games/cataclysm-dda/default.nix
··· 16 16 sha256 = "15l6w6lxays7qmsv0ci2ry53asb9an9dh7l7fc13256k085qcg68"; 17 17 }; 18 18 19 - patches = [ ./patches/fix_locale_dir.patch ]; 20 - 21 19 meta = with stdenv.lib.maintainers; common.meta // { 22 20 maintainers = common.meta.maintainers ++ [ skeidel ]; 23 21 };
-5
pkgs/games/cataclysm-dda/git.nix
··· 18 18 sha256 = "0ww2q5gykxm802z1kffmnrfahjlx123j1gfszklpsv0b1fccm1ab"; 19 19 }; 20 20 21 - patches = [ 22 - # Locale patch required for Darwin builds, see: https://github.com/NixOS/nixpkgs/pull/74064#issuecomment-560083970 23 - ./patches/fix_locale_dir_git.patch 24 - ]; 25 - 26 21 makeFlags = common.makeFlags ++ [ 27 22 "VERSION=git-${version}-${substring 0 8 src.rev}" 28 23 ];
-18
pkgs/games/cataclysm-dda/patches/fix_locale_dir.patch
··· 1 - --- a/src/translations.cpp 2 - +++ b/src/translations.cpp 3 - @@ -212,14 +212,12 @@ void set_language() 4 - auto env = getenv( "LANGUAGE" ); 5 - locale_dir = std::string( PATH_INFO::base_path() + "lang/mo/" + ( env ? env : "none" ) + 6 - "/LC_MESSAGES/cataclysm-dda.mo" ); 7 - -#elif (defined(__linux__) || (defined(MACOSX) && !defined(TILES))) 8 - +#else 9 - if( !PATH_INFO::base_path().empty() ) { 10 - locale_dir = PATH_INFO::base_path() + "share/locale"; 11 - } else { 12 - locale_dir = "lang/mo"; 13 - } 14 - -#else 15 - - locale_dir = "lang/mo"; 16 - #endif 17 - 18 - const char *locale_dir_char = locale_dir.c_str();
-20
pkgs/games/cataclysm-dda/patches/fix_locale_dir_git.patch
··· 1 - diff --git a/src/translations.cpp b/src/translations.cpp 2 - index 067e2cd77d..5660d18b3d 100644 3 - --- a/src/translations.cpp 4 - +++ b/src/translations.cpp 5 - @@ -211,14 +211,12 @@ void set_language() 6 - auto env = getenv( "LANGUAGE" ); 7 - locale_dir = std::string( FILENAMES["base_path"] + "lang/mo/" + ( env ? env : "none" ) + 8 - "/LC_MESSAGES/cataclysm-dda.mo" ); 9 - -#elif (defined(__linux__) || (defined(MACOSX) && !defined(TILES))) 10 - +#else 11 - if( !FILENAMES["base_path"].empty() ) { 12 - locale_dir = FILENAMES["base_path"] + "share/locale"; 13 - } else { 14 - locale_dir = "lang/mo"; 15 - } 16 - -#else 17 - - locale_dir = "lang/mo"; 18 - #endif 19 - 20 - const char *locale_dir_char = locale_dir.c_str();