Factor out union and resource types in .nix files