You gain 1 life. Target creature gets -X/-X until end of turn, where X is the amount of life you gained this turn.
Nightmareâ€™s Thirst counts how much life youâ€™ve gained this turn, not how much your life total changed. For example, if youâ€™ve gained 5 life and lost 8 before Nightmareâ€™s Thirst resolves, Nightmareâ€™s Thirst has you gain 1 more life, then it gives the target creature -6/-6.
If the target creature is an illegal target when Nightmareâ€™s Thirst tries to resolve, the spell doesnâ€™t resolve. You wonâ€™t gain 1 life.