What's the reason for doing this in Nix rather than C++? I'm worried about the performance implications of moving part of the attribute set processing into Nix code... Also, doing it in C++ prevents marshalling code like addAttrsAndPosition.