Adding entries to /etc/host in nixos

/etc/host is not changeable after you do a nixos-rebuild. So, I need to specify how to add entries during rebuild. How do you tell nixos to add entries to /etc/host?

as @tohl2 wrote, networking.extraHosts is what you are looking for.A convenient way to quickly check for options is the NixOS Options Website


You can also use networking.hosts if you prefer writing them in Nix. They’ll be merged with all the other hosts already in that file.

1 Like

Actually now that i know of this option, i’d rather prefer networking.hosts.
brb, rewriting all my modules and config!

1 Like