Set up your whole system in a config file. If you mess something up you can rollback any time (or in fact boot directly into past versions). You can patch bugs anywhere in your dependency tree easily. C/C++ packaging works. You can also deploy these configurations to remote machines.
Not sure about those two you mentioned but Ansible as a similar tool does not have state. It needs to run every command and check what changed. Nix, from my understanding, does have state so it can be more efficient.
The cool thing about Nix is that everything is compiled into a big immutable content-addressed store. Then switching the configuration is a matter of ensuring if that particular config has been built and switching some symlinks to the right place in the store.