lib: Use arithmetic operators rather than builtins.add etc.
Remove obsolete checks for missing primops
Use new primops
Replace hasAttr/getAttr calls with the ? and . operators

For NixOS evaluation, this gives a ~21% reduction in the number of
values allocated and a ~4% speedup. It's also more readable.
Eliminate some optionals/optionalAttrs calls on the hot path