Unable to build emscripten CMake program due to 64-bit dependency

I’m currently attempting to build an EasyRPG fork with Emscripten using the following script:

{
	buildEmscriptenPackage,
	fmt,
	freetype,
	harfbuzz,
	liblcf,
	libpng,
	nlohmann_json,
	pixman,
	SDL2,
	zlib,
	autoconf,
	automake,
	cmake,
	emscripten,
	gnum4,
	libtool,
	meson,
	pkg-config,
	ninja,
	unzip,
	which
}: buildEmscriptenPackage {
	pname = "minnaengine";
	version = "0.1.0";
	src = ./.;

	strictDeps = true;
	buildInputs = [
		fmt
		freetype
		harfbuzz
		liblcf
		libpng
		nlohmann_json
		pixman
		SDL2
		zlib
	];
	nativeBuildInputs = [
		autoconf
		automake
		cmake
		emscripten
		gnum4
		libtool
		meson
		pkg-config
		ninja
		unzip
		which
	];

	configurePhase = ''
		mkdir -p .emscriptencache/
		export EM_CACHE=$(pwd)/.emscriptencache/
		emcmake cmake . \
			-GNinja \
			-Bbuild \
			-DCMAKE_CXX_COMPILER_LAUNCHER="emcc" \
			-DCMAKE_BUILD_TYPE=Release \
			-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
			-DCMAKE_INSTALL_LIBDIR=lib \
			-DBUILD_SHARED_LIBS=OFF \
			-DSDL2_INCLUDE_DIR=${SDL2}/include \
			-DSDL2_LIBRARY=${SDL2}/lib \
			-DPLAYER_ENABLE_FMMIDI=OFF \
			-DPLAYER_WITH_MPG123=OFF \
			-DPLAYER_WITH_LIBSNDFILE=OFF \
			-DPLAYER_WITH_OGGVORBIS=OFF \
			-DPLAYER_WITH_WILDMIDI=OFF \
			-DPLAYER_WITH_FLUIDLITE=OFF \
			-DPLAYER_WITH_XMP=OFF \
			-DPLAYER_ENABLE_DRWAV=OFF \
			-DPLAYER_JS_BUILD_SHELL=ON \
			-DPLAYER_JS_OUTPUT_NAME=minnaengine \
			-DPLAYER_JS_GAME_URL=/data/ \
			-DCMAKE_CXX_FLAGS='-O3 -g0 -msimd128'
	'';
	buildPhase = ''
		ls
	'';
	checkPhase = "";
}

A lot of it is strictly provisional as I’m trying to get it working at the bare minimum before I polish it. I’m building it with nix-build and the initial configure phase seems to work fine until it tries to find fmt. It complains that it’s unable to find a version 5.2 for the package, instead finding a newer version that is 64-bit:

-- Build type is set to Release.
-- Found SDL2: /nix/store/dgvj2cvlyqp5513cjza6lmy2bah6vdqj-sdl2-compat-2.32.58/lib (Required is at least version "2.0.14")
-- Found liblcf: /nix/store/ms87qh2nm2irw3z5d2w224sadjf7g1y0-liblcf-0.8.1/lib/cmake/liblcf (liblcf::liblcf, v0.8.1)
-- Found ZLIB: /nix/store/l7xwm1f6f3zj2x8jwdbi8gdyfbx07sh7-zlib-1.3.1/lib/libz.so (found version "1.3.1")
-- Found PNG: /nix/store/s8md611ry6w14m4awmgivld52ym8s3b2-libpng-apng-1.6.50/lib/libpng.so (found version "1.6.50")
CMake Error at builds/cmake/Modules/PlayerFindPackage.cmake:66 (find_package):
  Could not find a configuration file for package "fmt" that is compatible
  with requested version "5.2".

  The following configuration files were considered but not accepted:

    /nix/store/nbzws3vkz282gf1p0mydxd28ckn8b0wr-fmt-12.0.0-dev/lib/cmake/fmt/fmt-config.cmake, version: 12.0.0 (64bit)

Call Stack (most recent call first):
  CMakeLists.txt:964 (player_find_package)


-- Configuring incomplete, errors occurred!

This is the CMakeLists line in question:

player_find_package(NAME fmt TARGET fmt::fmt VERSION 5.2 REQUIRED)

I’m unsure if the “version” parameter is referring to an exact version that it wants, or a minimum version; I’m going to assume it refers to a minimum version because it wouldn’t make much sense otherwise…?

So, from what I’ve read online, it seems that the problem here is that the package is 64-bit when it wants a 32-bit package? The build instructions recommend “fmtlib >= 6”. The name is rather vague so I assume it’s referring to that fmt, which I naturally inserted into the buildInputs. My confusion is that it seems to find all of the other dependencies up to this point with no issue at all, so has this package just not been built for the Emscripten target yet? I’m not sure what to do about this, or if this is even a nixpkgs problem or just an issue Nix has nothing to do with.

I am rather unfamiliar with both CMake and Emscripten, so any help would be appreciated… other people building the same software outside of Nix don’t seem to have run into this issue in particular.

Hey, first of all I’d like to point you to this valuable resource.

Now to your question. Have you tried patching the CMakeLists.txt? According to the find_package docs the version section can be omitted, so you can either remove the version section or increase the number to match a higher release of fmt.

You could accomplish this by adding this patch to the directory of your derivation with a name like fmt_version.patch:

--- a/CMakeLists.txt	2025-12-30 22:54:27.308383396 +0100
+++ b/CMakeLists.txt	2025-12-30 22:56:59.314717524 +0100
@@ -961,7 +961,7 @@
 # Detect all required libraries
 # PNG pulls in zlib which has a broken config when not both static and shared library are installed
 player_find_package(NAME PNG TARGET PNG::PNG REQUIRED CONFIG_BROKEN)
-player_find_package(NAME fmt TARGET fmt::fmt VERSION 5.2 REQUIRED)
+player_find_package(NAME fmt TARGET fmt::fmt REQUIRED)
 
 # Do not use player_find_package. enable_language used by pixman on Android does not work properly inside function calls
 find_package(Pixman REQUIRED)

And then you can add it to your derivation like so:

patches = [
  ./fmt_version.patch
];

You could place it after nativeBuildInputs for example.

Hopefully this was helpful, let me know if you have any questions.

Now, out of curiosity I ask, are you trying to build your package inside the configurePhase? Or is it a necessary step to build the real package? If that’s the case then maybe I’d suggest you to move it to preBuild, and then try to not specify anything in the buildPhase (remove it altogether) because nix is really good at figuring out how to build your package (unless you get error and you have to manually intervene, that is). I hope I was helpful, good luck!

Hi, thank you for responding. Omitting the version specifier doesn’t work; replace Could not find a configuration file for package "fmt" that is compatible with requested version "5.2". with just Could not find a configuration file for package "fmt" that is compatible with requested version "". and that’s what happens. I suspect it’s because the package is 64-bit, but I don’t know why that would be a problem.

I should mention that, yes, this is necessary for building the package. It takes place before cmake build is run, and is listed as a configuration step in the building documentation (or lack thereof, I suppose). I will try to place it in preBuild though, and see if that makes it easier barring the fmt problem I’m having presently.