How to add cmake-commands to cmake derivation?

I’m currently trying to create a new package for vulkan-loader to enable adress sanitizer and debug flags.

I got this far by simply copy-pasting the upstream package and adding cmakeBuildType = "Debug";. Now I’m stuck at finding out how to add cmake-commands (specifically add_compile_options and add_link_options, to add -fsanitize=address) to the derivation. I couldn’t find anything in the docs.

What would you suggest?

You don’t need to add those commands as such; you can set

  cmakeFlags = [
    (lib.cmakeFeature "CMAKE_C_FLAGS" "-fsanitize=address")
  ];

If you do ever actually need to add commands, I’d do that by printing them >> CMakeLists.txt in postPatch. See pkgs/by-name/es/espeak-ng/package.nix, for example.