diff --git a/pkgs/by-name/np/np2kai/1001-CMakeLists.txt-Fix-CMAKE_CXX_FLAGS_-RELEASE-DEBUG.patch b/pkgs/by-name/np/np2kai/1001-CMakeLists.txt-Fix-CMAKE_CXX_FLAGS_-RELEASE-DEBUG.patch new file mode 100644 index 000000000000..7762e0a27f48 --- /dev/null +++ b/pkgs/by-name/np/np2kai/1001-CMakeLists.txt-Fix-CMAKE_CXX_FLAGS_-RELEASE-DEBUG.patch @@ -0,0 +1,33 @@ +From 3d23274eefcf9c494358662539c29eebd8996cbf Mon Sep 17 00:00:00 2001 +From: OPNA2608 +Date: Mon, 23 Feb 2026 17:00:24 +0100 +Subject: [PATCH 1/3] CMakeLists.txt: Fix CMAKE_CXX_FLAGS_{RELEASE,DEBUG} being + lists of strings + +g++ /* ... */ -O2 -Wall -DNDEBUG;-Wno-implicit-function-declaration -Wno-incompatible-pointer-types /* ... */ -o CMakeFiles/sdlnp2kai_sdl2.dir/sound/fmgen/fmgen_file.cpp.o -c /build/source/sound/fmgen/fmgen_file.cpp +ld: /lib/Scrt1.o: in function `_start': +(.text+0x1b): undefined reference to `main' +collect2: error: ld returned 1 exit status +bash: line 1: -Wno-implicit-function-declaration: command not found +--- + CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5a9884f..9c14d94 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -323,8 +323,8 @@ if(NOT CMAKE_BUILD_TYPE) + endif() + if(NOT EMSCRIPTEN) + set(COMMON_C_CXX_FLAGS "-Wno-implicit-function-declaration -Wno-incompatible-pointer-types -Wno-incompatible-function-pointer-types -Wno-int-conversion -fno-sized-deallocation") +-set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall -DDEBUG -DTRACE" ${COMMON_C_CXX_FLAGS}) +-set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall -DNDEBUG" ${COMMON_C_CXX_FLAGS}) ++set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall -DDEBUG -DTRACE ${COMMON_C_CXX_FLAGS}") ++set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall -DNDEBUG ${COMMON_C_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -Wall") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Og -g -Wall -DNDEBUG") + endif() +-- +2.52.0 + diff --git a/pkgs/by-name/np/np2kai/1002-sdl-x-fontmng.c-Fix-GlyphMetrics-calls.patch b/pkgs/by-name/np/np2kai/1002-sdl-x-fontmng.c-Fix-GlyphMetrics-calls.patch new file mode 100644 index 000000000000..0cb6c396a30f --- /dev/null +++ b/pkgs/by-name/np/np2kai/1002-sdl-x-fontmng.c-Fix-GlyphMetrics-calls.patch @@ -0,0 +1,72 @@ +From a6b3a5d71c9c31b690f8045ba2fd6d9c529da92c Mon Sep 17 00:00:00 2001 +From: OPNA2608 +Date: Mon, 23 Feb 2026 17:18:58 +0100 +Subject: [PATCH 2/3] {sdl,x}/fontmng.c: Fix GlyphMetrics calls + +/build/source/sdl/fontmng.c:503:58: error: passing argument 2 of 'TTF_GlyphMetrics' makes integer from pointer without a cast [-Wint-conversion] +In file included from /build/source/sdl/fontmng.c:20: +/include/SDL2/SDL_ttf.h:800:69: note: expected 'Uint16' {aka 'short unsigned int'} but argument is of type 'SDL_Surface *' +--- + sdl/fontmng.c | 8 ++++---- + x/fontmng.c | 8 ++++---- + 2 files changed, 8 insertions(+), 8 deletions(-) + +diff --git a/sdl/fontmng.c b/sdl/fontmng.c +index 487e563..27b7a47 100644 +--- a/sdl/fontmng.c ++++ b/sdl/fontmng.c +@@ -498,9 +498,9 @@ static void TTFGetFont1(FNTMNG _this, FNTDAT fdat, UINT16 c) + { + #if !defined(_WINDOWS) + #if USE_SDL_VERSION >= 3 +- TTF_GetGlyphMetrics(_this->ttf_font,s,&minx,NULL,NULL,&maxy,&advance); ++ TTF_GetGlyphMetrics(_this->ttf_font,c,&minx,NULL,NULL,&maxy,&advance); + #else +- TTF_GlyphMetrics(_this->ttf_font,s,&minx,NULL,NULL,&maxy,&advance); ++ TTF_GlyphMetrics(_this->ttf_font,c,&minx,NULL,NULL,&maxy,&advance); + #endif + #endif + for (y = 0; y < fdat->height; y++) +@@ -532,9 +532,9 @@ static void TTFGetFont1(FNTMNG _this, FNTDAT fdat, UINT16 c) + { + #if !defined(_WINDOWS) + #if USE_SDL_VERSION >= 3 +- TTF_GetGlyphMetrics(_this->ttf_font,s,&minx,NULL,NULL,&maxy,&advance); ++ TTF_GetGlyphMetrics(_this->ttf_font,c,&minx,NULL,NULL,&maxy,&advance); + #else +- TTF_GlyphMetrics(_this->ttf_font,s,&minx,NULL,NULL,&maxy,&advance); ++ TTF_GlyphMetrics(_this->ttf_font,c,&minx,NULL,NULL,&maxy,&advance); + #endif + #endif + for (y = 0; y < fdat->height; y++) +diff --git a/x/fontmng.c b/x/fontmng.c +index a284ba6..01ed817 100755 +--- a/x/fontmng.c ++++ b/x/fontmng.c +@@ -484,9 +484,9 @@ static void TTFGetFont1(FNTMNG _this, FNTDAT fdat, UINT16 c) + if (_this->fonttype & FDAT_ALIAS) + { + #if USE_SDL_VERSION >= 3 +- TTF_GetGlyphMetrics(_this->ttf_font,s,&minx,NULL,NULL,&maxy,&advance); ++ TTF_GetGlyphMetrics(_this->ttf_font,c,&minx,NULL,NULL,&maxy,&advance); + #else +- TTF_GlyphMetrics(_this->ttf_font,s,&minx,NULL,NULL,&maxy,&advance); ++ TTF_GlyphMetrics(_this->ttf_font,c,&minx,NULL,NULL,&maxy,&advance); + #endif + for (y = 0; y < fdat->height; y++) + { +@@ -510,9 +510,9 @@ static void TTFGetFont1(FNTMNG _this, FNTDAT fdat, UINT16 c) + else + { + #if USE_SDL_VERSION >= 3 +- TTF_GetGlyphMetrics(_this->ttf_font,s,&minx,NULL,NULL,&maxy,&advance); ++ TTF_GetGlyphMetrics(_this->ttf_font,c,&minx,NULL,NULL,&maxy,&advance); + #else +- TTF_GlyphMetrics(_this->ttf_font,s,&minx,NULL,NULL,&maxy,&advance); ++ TTF_GlyphMetrics(_this->ttf_font,c,&minx,NULL,NULL,&maxy,&advance); + #endif + for (y = 0; y < fdat->height; y++) + { +-- +2.52.0 + diff --git a/pkgs/by-name/np/np2kai/1003-sdl-np2.c-Fix-wrong-order-of-arguments-to-fgets-call.patch b/pkgs/by-name/np/np2kai/1003-sdl-np2.c-Fix-wrong-order-of-arguments-to-fgets-call.patch new file mode 100644 index 000000000000..d7a06cccc55a --- /dev/null +++ b/pkgs/by-name/np/np2kai/1003-sdl-np2.c-Fix-wrong-order-of-arguments-to-fgets-call.patch @@ -0,0 +1,27 @@ +From 697fac371b414212526aae25e7c9774f167f4ef3 Mon Sep 17 00:00:00 2001 +From: OPNA2608 +Date: Mon, 23 Feb 2026 17:26:26 +0100 +Subject: [PATCH 3/3] sdl/np2.c: Fix wrong order of arguments to fgets call + +/build/source/sdl/np2.c:373:19: error: passing argument 2 of 'fgets' makes integer from pointer without a cast [-Wint-conversion] +/build/source/sdl/np2.c:373:25: error: passing argument 3 of 'fgets' makes pointer from integer without a cast [-Wint-conversion] +--- + sdl/np2.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sdl/np2.c b/sdl/np2.c +index 6712ac1..002ee33 100755 +--- a/sdl/np2.c ++++ b/sdl/np2.c +@@ -370,7 +370,7 @@ char np2_main_read_m3u(const char *file) + #if defined(__LIBRETRO__) + while (filestream_gets(f, line, sizeof(line)) && np2_main_disk_images_count < sizeof(np2_main_disk_images_paths) / MAX_PATH) + #else +- while (fgets(f, line, sizeof(line)) && np2_main_disk_images_count < sizeof(np2_main_disk_images_paths) / MAX_PATH) ++ while (fgets(f, sizeof(line), line) && np2_main_disk_images_count < sizeof(np2_main_disk_images_paths) / MAX_PATH) + #endif + { + if (line[0] == '#') +-- +2.52.0 + diff --git a/pkgs/by-name/np/np2kai/package.nix b/pkgs/by-name/np/np2kai/package.nix index 5525d71aa349..3245c09ad3fb 100644 --- a/pkgs/by-name/np/np2kai/package.nix +++ b/pkgs/by-name/np/np2kai/package.nix @@ -15,48 +15,53 @@ pkg-config, SDL2, SDL2_ttf, - SDL2_mixer, enable16Bit ? true, enableX11 ? stdenv.hostPlatform.isLinux, - # HAXM build succeeds but the binary segfaults, seemingly due to the missing HAXM kernel module - # Enable once there is a HAXM kernel module option in NixOS? Or somehow bind it to the system kernel having HAXM? - # Or leave it disabled by default? - # https://github.com/intel/haxm/blob/master/docs/manual-linux.md - enableHAXM ? false, }: stdenv.mkDerivation (finalAttrs: { pname = "np2kai"; - version = "0.86rev22-unstable-2025-09-13"; + version = "0.86rev22-unstable-2026-02-08"; src = fetchFromGitHub { owner = "AZO234"; repo = "NP2kai"; - rev = "02b08deb3833305251fb3ee6c5d59b0efb5b52ff"; - hash = "sha256-5aGlqYS05rUh+mD9TdCC9H+5JkOQCTn45UlEu7xcxLw="; + rev = "44c8a8c61640f2d5476af5224dbd88a36079f45d"; + hash = "sha256-zLhUkUojsjMYN75jsPa3OHOdv79MmMVvwlvuYC6NZqA="; }; - # Don't require Git - # Use SDL2(_*) targets for correct includedirs - # Add return type in ancient code + patches = [ + # https://github.com/AZO234/NP2kai/pull/202 + ./1001-CMakeLists.txt-Fix-CMAKE_CXX_FLAGS_-RELEASE-DEBUG.patch + ./1002-sdl-x-fontmng.c-Fix-GlyphMetrics-calls.patch + ./1003-sdl-np2.c-Fix-wrong-order-of-arguments-to-fgets-call.patch + ]; + + # - Don't require Git postPatch = '' substituteInPlace CMakeLists.txt \ - --replace-fail 'if(NOT git_result EQUAL 0)' 'if(FALSE)' \ - --replace-fail "\''${SDL2_DEFINE}" "" \ - --replace-fail "\''${SDL2_INCLUDE_DIR}" "" \ - --replace-fail "\''${SDL2_LIBRARY}" "SDL2::SDL2" \ - --replace-fail "\''${SDL2_MIXER_DEFINE}" "" \ - --replace-fail "\''${SDL2_MIXER_INCLUDE_DIR}" "" \ - --replace-fail "\''${SDL2_MIXER_LIBRARY}" "SDL2_mixer::SDL2_mixer" \ - --replace-fail "\''${SDL2_TTF_DEFINE}" "" \ - --replace-fail "\''${SDL2_TTF_INCLUDE_DIR}" "" \ - --replace-fail "\''${SDL2_TTF_LIBRARY}" "SDL2_ttf::SDL2_ttf" \ - - substituteInPlace x/cmserial.c \ - --replace-fail 'convert_np2tocm(UINT port, UINT8* param, UINT32* speed) {' 'int convert_np2tocm(UINT port, UINT8* param, UINT32* speed) {' - substituteInPlace x/gtk2/gtk_menu.c \ - --replace-fail 'xmenu_visible_item(MENU_HDL hdl, const char *name, BOOL onoff)' 'int xmenu_visible_item(MENU_HDL hdl, const char *name, BOOL onoff)' + --replace-fail 'if(NOT git_result EQUAL 0)' 'if(FALSE)' + '' + # Directory included is /include/SDL2 + + '' + substituteInPlace {sdl,x}/fontmng.c \ + --replace-fail '' '' + '' + # https://github.com/AZO234/NP2kai/issues/203 + # This really needs to be adjusted abit to really be POSIX-compliant & still Windows-compatible, but at least on Linux this should be fine... + + '' + substituteInPlace network/net.c \ + --replace-fail 'np2net_hThreadR = NULL' 'np2net_hThreadR = 0' \ + --replace-fail 'np2net_hThreadW = NULL' 'np2net_hThreadW = 0' + '' + # Stub out the IDE dialogue when the target doesn't support IDE + # https://github.com/AZO234/NP2kai/issues/204 + + '' + echo '#ifdef SUPPORT_IDEIO' > tmp + cat x/gtk2/dialog_ide.c >> tmp + echo '#endif' >> tmp + mv tmp x/gtk2/dialog_ide.c ''; strictDeps = true; @@ -73,7 +78,6 @@ stdenv.mkDerivation (finalAttrs: { openssl SDL2 SDL2_ttf - SDL2_mixer ] ++ lib.optionals enableX11 [ fontconfig @@ -84,21 +88,19 @@ stdenv.mkDerivation (finalAttrs: { ]; cmakeFlags = [ - (lib.cmakeBool "BUILD_SDL" true) - (lib.cmakeBool "BUILD_X" enableX11) - (lib.cmakeBool "BUILD_HAXM" enableHAXM) - (lib.cmakeBool "BUILD_I286" enable16Bit) + (lib.strings.cmakeBool "BUILD_SDL" true) + (lib.strings.cmakeBool "BUILD_X" enableX11) + (lib.strings.cmakeBool "BUILD_I286" enable16Bit) + (lib.strings.cmakeBool "BUILD_HAXM" false) - (lib.cmakeBool "USE_SDL" true) - (lib.cmakeBool "USE_SDL2" true) - (lib.cmakeBool "USE_SDL_MIXER" true) - (lib.cmakeBool "USE_SDL_TTF" true) - (lib.cmakeBool "USE_X" enableX11) - (lib.cmakeBool "USE_HAXM" enableHAXM) + (lib.strings.cmakeBool "USE_SDL3" false) # WIP, doesn't really seem to build yet + (lib.strings.cmakeBool "USE_SDL2" true) + (lib.strings.cmakeBool "USE_SDL" true) + (lib.strings.cmakeBool "USE_SDL_TTF" true) + (lib.strings.cmakeBool "USE_X" enableX11) + (lib.strings.cmakeBool "USE_HAXM" false) ]; - enableParallelBuilding = true; - env = { NP2KAI_VERSION = finalAttrs.version; NP2KAI_HASH = builtins.substring 0 7 finalAttrs.src.rev;