There's some prospect of Nickel (https://github.com/tweag/nickel) meeting this need, though haven't tried it and can't really vouch.
Typing might be really helpful for building your own layers up, but I don't know if it can meaningfully help with problems around consuming existing Nix ~APIs.