system
Given the following post, respond as if you're commenting on Reddit:
human
[Warhammer 40k] So let's say the worst has happened and the main Tyranid Hive Swarm has reached Holy Terra. How long can the defenses hold before they're consumed?

Let's have two scenarios, in the first one somehow the Genestealer Cult actually grew big enough to sabotage some defenses and effectively makes it easier for the Swarm to invade. Second one no cult uprising ever happens, they just wake up one day with the Hive Swarm coming in. How fucked is the Imperium?
gpt
Of course it would depend on what you mean by a Tyranid Hive Swarm. Hive Fleets like Leviathan or Behemoth though a great threat in the Milky Way Galaxy, are merely a scouting party of the potentially much much larger Tyranid Swarm outside of it.

If you mean the Tyranids as a whole, Terra has no chance. 

If you mean something like a Hive Fleet like Behemoth or Leviathan, it is unlikely that Holy Terra would be taken. MaCragge has a fraction of Terra's defenses and it held against Hive Fleet Behemoth.

The Tyranids' Shadow of in the Warp which blocks communications with outside systems is much less effective, because most planets in the Imperium pays some sort of tribute to Holy Terra, word of a Tyranid invasion on Holy Terra will quickly spread to other systems in the Imperium. 

Holy Terra also has many powerful factions in the Solar System:

* The Headquarters of the Grey Knights, based on Titan.
* The Headquarters of the Ordo Malleus, based on Saturn.
* The Headquarters of the Adeptus Mechanicus, based on Mars.
* The Custodes who guard the Emperor, call Terra their home. 

On top of these, Terra's Moon, Luna is a giant space cannon. There is a massive Imperial Shipyard on Jupiter, as well as another massive Shipyard belonging to the Mechanicus on it's moons. Much of Terra's fortifications that were built by Rogal Dorn himself remain mostly intact.

Regarding sabotage by the genestealers, there would have to be massive systemic failure from multiple organizations for the genestealer cults to have a significant impact on its planetary defenses. There have been genestealer cults on Terra before but they are quickly quarantined and purged by the Inquisition. But even if it were the case, Terra just has too many powerful organizations on the planet itself and within its solar system for genestealers to cause significant damage.