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
1 changed files with 13 additions and 5 deletions

View File

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