Nissan may have done something like that, but I'm just basically referring to Toyota's. Toyota has been pretty consistent in their styling of sun/moon roofs over the years. The whole roof of a vehicle is different if it has a factory sunroof vs. one without one because the factory sunroofs are molded into the roof lines, the metal is rolled downwards for the rubber edge gasket to seal up against, the headliners are molded differently and typically dropped down an inch or two, and the substructure cross-bracing supporting the roof are located differently etc.... Some vehicles are not capable of having an aftermarket sunroof installed if a factory cross-brace is in the way. A sunroof installer would not want the liability of cutting a safety feature, and even if they did, it can be difficult to cut around it and get things to line up or seal correctly.
Aftermarket sunroofs (which are common) are just a hole cut into the roof, and there are two styles to accommodate hard vs. soft headliners. With soft headliners, the headliner isn't cut open as large as the hole in the metal roof. The headliner gets tucked into the actual sunroof structure itself, then a cover is screwed in over it (sometimes there's a piece of rubber/plastic trim that then covers up the screws). I've installed this style of sunroof myself a few times. The other type of sunroof is for hard headliners, and the headliner is trimmed as large as the hole in the metal roof, and a piece of trim is screwed on to the underside of the sunroof frame that extends out passed the hole you cut (if you cut the hole too big, the trim won't cover it up).
Most aftermarket sunroofs are the basic pop-up manual style in which the glass can be removed completely, but there are aftermarket electric roofs. These typically have long brackets that will extend themselves out of the vehicle and rearwards and take the whole sheet of glass with it. Electric aftermarket sunroof panels have to go somewhere when they are slid back, and they normally go outside the vehicle because there isn't enough room under most headliners (of vehicles not equipped with a factory sunroof already).