Configuring to shutdown after failed logins

Is there any way to configure my system using the security.pam module to shutdown the system after the nth incorrect login? I am trying to reproduce the behaviour as specified in this post. I am new to Nixos so have not got very far. I’ve not managed to get the simpler Lock out user after failed login attempts working which would be better although not what I am ultimately aiming for.