If you just had your nose broken and the guy who broke your nose who is continuing to beat on you of you has you trapped and says he's going to kill you and you have a gun and you use it - that's self defense.
Your attacker in the heat of the moment can not have as much right to beat you to death as you have to defend yourself.
It makes no difference whether your job was to follow him or not to reduce neighborhood crime. It makes no difference whatsoever what caused him to start beating on you, or why he is upset with you.
The guy just had a bloody nose. He got off lucky.