Also, what is your opinion on Remove NIX_CFLAGS_COMPILE where possible · Issue #79303 · NixOS/nixpkgs · GitHub ?
This issue states that NIX_CFLAGS_COMPILE is a hack that allows to bypass the build system and that it’s better to use the build system. This sounds accurate. The issue you have is that you don’t know how to coerce the build system (in the broader sense that includes the stdenv configuration machinery) to achieve what you want, and in the absence a better solution, this is precisely the use case for NIX_CFLAGS_COMPILE.