Patching nixpkgs before import

Is there a way to apply a patch to a copy of nixpkgs before running ‘import’ on it?

In particular, I have something that I want to add globally to nixpkgs CFLAGS, and the only way I could figure to do it would be patching cc-wrapper. Since cc-wrapper is not a normal nix package, I can’t use overlays. I could create a separate fork of nixpkgs just for this change, but I’d rather apply a patch, especially since the patch I’d like to apply depends on a variable.

Related to (Compiling with old glibc), in that this is another attempt to get binaries working with older versions of glibc.

Oh, I’ve just seen this: Support patching nixpkgs which goes into the matter. It points out problems with this approach which I’m not sure how to solve, so I guess I rescind my question until I’ve done further research.