From c57892462bf22e537a2cd5ee5e6f88b0b59a2d33 Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Sun, 23 Sep 2018 15:55:39 +0000 Subject: [PATCH] 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. --- nixos/modules/config/networking.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nixos/modules/config/networking.nix b/nixos/modules/config/networking.nix index a1ee6a4304a..1eb6fb43604 100644 --- a/nixos/modules/config/networking.nix +++ b/nixos/modules/config/networking.nix @@ -215,6 +215,8 @@ in networking.hosts = { "127.0.0.1" = [ "localhost" ]; + } // optionalAttrs (cfg.hostName != "") { + "127.0.1.1" = [ cfg.hostName ]; } // optionalAttrs cfg.enableIPv6 { "::1" = [ "localhost" ]; };