From 13841d6e47a54a6ec5c0c501a9d19d23fc081b2d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 6 Oct 2012 21:00:26 -0400 Subject: [PATCH] Use nss-myhostname to ensure that the hostname resolves to something sensible --- modules/config/nsswitch.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/config/nsswitch.nix b/modules/config/nsswitch.nix index 7c969320b3d..4c46e8ec87d 100644 --- a/modules/config/nsswitch.nix +++ b/modules/config/nsswitch.nix @@ -48,7 +48,7 @@ in passwd: files ldap group: files ldap shadow: files ldap - hosts: files ${optionalString nssmdns "mdns_minimal [NOTFOUND=return]"} dns ${optionalString nssmdns "mdns"} + hosts: files ${optionalString nssmdns "mdns_minimal [NOTFOUND=return]"} dns ${optionalString nssmdns "mdns"} myhostname networks: files dns ethers: files services: files @@ -58,6 +58,11 @@ in } ]; + # Use nss-myhostname to ensure that our hostname always resolves to + # a valid IP address. It returns all locally configured IP + # addresses, or ::1 and 127.0.0.2 as fallbacks. + system.nssModules = [ pkgs.nss_myhostname ]; + environment.shellInit = if config.system.nssModules.path != "" then ''