Generating secret key of hidden service.

Hi,
Does anyone know how exactly secretKey and onionUrl are generated? I’m trying to find information if generating custom secretKeys is possible? By custom I mean secretKeys that are generated based on some value so two different machines can generate the same secretKey based on that value.
If anyone have any information about that or know where to look for it, please leave a comment.
Have a great day!