Adding the hostname.domain and localhost.domain to hosts, if possible.

Postfix likes this.


svn path=/nixos/trunk/; revision=30362
This commit is contained in:
Lluís Batlle i Rossell 2011-11-09 21:02:01 +00:00
parent 578f83eef4
commit de5eedb612

View File

@ -2,7 +2,9 @@
{config, pkgs, ...}: {config, pkgs, ...}:
with pkgs.lib;
let let
cfg = config.networking;
options = { options = {
@ -16,6 +18,13 @@ let
}; };
localhostWithDomain = optionalString (cfg.domain != "")
"localhost.${cfg.domain}";
hostnameWithDomain = optionalString
(cfg.domain != "" && cfg.hostName != "")
"${cfg.hostName}.${cfg.domain}";
in in
{ {
@ -40,11 +49,10 @@ in
{ # /etc/hosts: Hostname-to-IP mappings. { # /etc/hosts: Hostname-to-IP mappings.
source = pkgs.writeText "hosts" source = pkgs.writeText "hosts"
'' ''
${config.networking.extraHosts} ${cfg.extraHosts}
${if config.networking.hostName != "" ${optionalString (cfg.hostName != "")
then "127.0.0.1 ${config.networking.hostName}" "127.0.0.1 ${cfg.hostName} ${hostnameWithDomain}"}
else ""} 127.0.0.1 localhost ${localhostWithDomain}
127.0.0.1 localhost
''; '';
target = "hosts"; target = "hosts";
} }