Usually if you screw up the configuration.nix
you can rollback to a previous generation during boot.
Then you use https://nixos.org/nixos/manual/#sec-rollback to fix the rollback generation.
However if you really screw it up, and none of the generations work, you may need use a recovery method.
Get a NixOS ISO (it's best to get one that has a same or similar version as your current one).