I know this thread is from a while ago - but I’ll throw this it anyway -There is of course an exception.
In any composed word, where the first one ends in n and the second starts with g. If the following letter is a hard vowel (aouå) or any consonant except j the n is pronounced as ŋ, followed by g, while if followed by a soft vowel (eiyäö) or j, the n is pronounced as n and the g takes a j sound.
Any idea why the g in the word ‘fegis’ (coward) is pronounced hard in Swedish and not the usual soft?
Is it a loan word from another language?