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
A stored spell (probably) has the same range as the normal version of that spell
There is nothing in Glyph of Warding's text that explicitly states a maximum or minimum range at which it can cast a spell. The Range for Glyph of Warding itself is "Touch", but that is presumably to create the Glyph, not for effects the Glyph creates. The Glyph itself can "cover an area up to 10 feet in diameter", but that does not necessarily mean its effects are limited to this area.
There is a small hint in the text that the Glyph can effect things which are not touching it. Specifically, amongst the possible triggers it states (PHB, p. 245 bold added)
However, this does not tell us definitively whether or not the Spell Glyph can cause effects at any particular range. After all, the the Explosive Runes version of Glyph of Warding effects things in a 20 foot radius sphere centered on the Glyph, so a trigger of "when a creature comes within 15 feet of the Glyph" would be a reasonable (if often sub-optimal) trigger for that feature alone.
The biggest hint we have is simply the description of what happens when a Spell Glyph is triggered (PHB, p. 246, bold added):
The triggering of the glyph will cast the spell you stored in it, in your case Greater Restoration. The spell will have all the qualities that it usually does, including range, duration, and effects.1
If Glyph of Warding changed features of the spells it "casts", its text would say so. Since it does not, the Range of the stored spell most likely remains unchanged. So a creature would need to be touching the Glyph of Warding in order to benefit from a stored spell of Greater Restoration, since Greater Restoration's range is Touch. If the stored spell had a longer range, that range would be used instead. For example, if you stored the spell Haste into a Glyph of Warding, the Glyph could target any creature that triggered it with a Haste spell as long as that creature was within 30 feet of the Glyph (the range of Haste being 30 feet).
1: The only feature of the spell we can be sure will change when it is triggered (besides "concentration") is its components: the components are necessary for "casting" the spell (so you presumably needed them when you "cast the spell" as part of the casting of Glyph of Warding), but we are already told that "the stored spell is cast" when the glyph is triggered without any caveats (which is good, since the Glyph has no hands to gesture somatically or mouth to speak the verbal components). So the components will be unnecessary when the spell is triggered, the same way it would be unnecessary to pay gold for an item that a spell magically created, even though that item usually costs gold at a store.