It's like Ansible but with a proper language, declarative instead of imperative config, a lot less leaky and brittle, a huge amount of pre-made packages and config, and can manage the entire OS. Not really the same class as Ansible actually. I used Ansible at first and it felt super hacky and broke all the time. Nix is light years ahead in reliability and power.
Don't know anything about Terraform.