u/CarpenterOk2025

▲ 9 r/Nix+1 crossposts

I’m currently packaging a C++ project using stdenv.mkDerivation and I am using msgpack-cxx as a dependency.Since it is a header-only library, I’ve placed it under nativeBuildInputs. However, the resulting build still contains a runtime reference to the msgpack-cxx store path.

Because msgpack-cxx depends on Boost, this adds over 130MB to my closure size, which is unacceptable for my specific deployment.

Here is my Minimum code demon:

typedef enum
{
    TCP = 0,
    UDP,
} SIMPLE_TYPE;
MSGPACK_ADD_ENUM(SIMPLE_TYPE);

typedef struct
{
    SIMPLE_TYPE type;
    std::string name;
    MSGPACK_DEFINE_MAP(type, name)
} SIMPLE_OBJ;

SIMPLE_OBJ simpleObj;
simpleObj.name = "test";
simpleObj.type = TCP;

printf("%s", simpleObj.name.c_str());

msgpack::sbuffer sbuf;
msgpack::pack(sbuf, simpleObj);
std::string dataPack = std::string(sbuf.data(), sbuf.size());
  • If I only use MSGPACK_DEFINE_MAP to define my structures, there is no runtime reference.
  • As soon as I call msgpack::pack(...) in my code, the resulting binary references the Nix store path of the headers, and I can't seem to get rid of it.
reddit.com
u/CarpenterOk2025 — 17 days ago