git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/networking: add hostname to `/etc/hosts` by default

We use `127.0.1.1` instead of `127.0.0.1` because some applications will fail if `127.0.0.1` resolves to something other than `localhost`. Debian does the same. See #1248 and #36261.

commitc57892462bf22e537a2cd5ee5e6f88b0b59a2d33 authorJan Malakhovski <oxij@oxij.org> dateSun 23 Sep 2018, 15:55 (8 years ago) parent1ece504
1 file changed+2
nixos/modules/config/networking.nix+2
nixos/modules/config/networking.nix+2
@@ -215,6 +215,8 @@ in
215215
216216 networking.hosts = {
217217 "127.0.0.1" = [ "localhost" ];
218+ } // optionalAttrs (cfg.hostName != "") {
219+ "127.0.1.1" = [ cfg.hostName ];
218220 } // optionalAttrs cfg.enableIPv6 {
219221 "::1" = [ "localhost" ];
220222 };