The law that restricts who the president may nominate, for the cabinet, should be unconstitutional, unless it’s a constitutional amendment.
The Cabinet isn’t in the Constitution, except to note that the President can ask the opinions of the heads of Executive departments. Those departments are *completely* a creation of Congress, who can restrict them as they see fit.