It depends on how you use the Wish
Wish has, principally, two different classes of use:
- Duplicate the effects of a spell
- Cause something else to happen; take backlash damage from the Stress of the spell
This means that, in practice, you have two options for bringing a Glyph of Warding into existence:
- Duplicate a Glyph of Warding spell exactly as written, meaning you still need to use the second spell slot and are limited to providing only spells that you are capable of preparing (and have prepared at the time you cast Wish
- Create a Glyph of Warding with whatever spell you want (and maybe an additional effect? It's your wish...), no longer needing to spend the second spell slot or have the spell prepared; take backlash damage from the Stress of the spell.
There is one wrinkle in the former use of the Wish though:
The basic use of this spell is to duplicate any other spell of 8th level or lower. You don't need to meet any requirements in that spell, including costly components. The spell simply takes effect.
What, exactly, constitutes a "Requirement ignored by Wish" is the subject of considerable debate. Based on that post, Requirements is here intended to refer to things like cast-time, material components, spell lists, preparation, etc.. I don't think it would permit you to ignore the requirements to
- Have the spell that you plan to place within the Glyph prepared
- Be capable of spending the necessary spell slot to cast the spell you plan to place in the Glyph
Unless, of course, your DM decides to rule that those requirements can be handwaved as part of the "ignore the spell's requirements" stipulation.
There is no limit to the trigger, but the spell may fail
Please stop being evil's answer shows well that there is no actual distance limit to the triggering event. This answer argues that there is still a practical distance limit for most purposes.
I assume in this answer that the spell is being cast from the glyph's space for the purpose of targeting.
The text is fairly clear that the effect of explosive runes is centered on the glyph. A spell glyph is a little less straightforward, but there are still limitations.
Spell Glyph: You can store a prepared spell of 3rd level or lower in the glyph by casting it as part of creating the glyph. The spell must target a single creature or an area. The spell being stored has no immediate effect when cast in this way. When the glyph is triggered, the stored spell is cast. If the spell has a target, it targets the creature that triggered the glyph. If the spell affects an area, the area is centered on that creature. If the spell summons hostile creatures or creates harmful objects or traps, they appear as close as possible to the intruder and attack it. If the spell requires concentration, it lasts until the end of its full duration.
Lets use this in the context of your Drow alarm example. We know that the spell is cast immediately when the triggering condition is met, and since the spell doesn't say otherwise, one mile is a viable distance. However, the area of effect must be centered on the creature, and there is no point of origin that can accomplish this within the spell's range. Thus, even though the glyph is triggered, when the spell is cast, the necessary target is not in range. When there is no valid target, the spell usually fails and is wasted, see this answer for details.
Your plan is clever, and though I would allow it at my table, there is no RAW reason for the glyph to 'aim' as close as possible, so by the rules, the glyph would be spent, with no boom. Note that an explosive rune does not target anything, so an explosive rune using thunder magic could reasonably still provide an audible alarm, due to the sound based nature of thunder damage. By monitoring a summons glyph, you could identify the direction of the Drow by where the summons appear, since they are specifically stated to appear "as close as possible" to the triggering creature.
By contrast, in your Fireball example, the triggering creature is within the spell's range. The area 'chosen' by the glyph (centered on triggering creature) and the area possible from the Fireball spell (point of origin within 150 ft of the spell's casting) do not contradict each other, so the spell succeeds.
Best Answer
This doesn't quite work the way you say
Most of your technique tracks with the rules, but Step 3 does not.
Wish is a 9th level spell, and glyph of warding specifies:
So, you cannot store a 9th level spell like wish in an 8th level glyph of warding.
However, you could simply store simulacrum (a 7th level spell) in an 8th or 9th level glyph of warding, and this plan works fine. It would just take 12 hours (casting simulacrum) and "powdered ruby worth 1,500 gp" in addition to the 200 gp cost of the glyph of warding.