Add `config.define_derived_metadata`.

Fixes #969 and supercedes #1089.