In case I need to modify my /etc/hosts I use the main configuration.nix file but the problem with this file it will rebuild the whole system again and that might take too much time depending on your configuration… Is there a fast way to just modify /etc/hosts directly using nix or any other way ?
If you set environment.etc.hosts.mode = "0644";, you can modify the file as root. Note that changes made in this way will be discarded when switching configurations. I used this to make vagrant’s hostmanager work though, and it worked pretty smoothly.