diff --git a/nixos/modules/config/networking.nix b/nixos/modules/config/networking.nix
index d503f5a8b20..ea9e8b712c6 100644
--- a/nixos/modules/config/networking.nix
+++ b/nixos/modules/config/networking.nix
@@ -20,12 +20,24 @@ in
options = {
+ networking.extraLocalHosts = lib.mkOption {
+ type = types.listOf types.str;
+ default = [];
+ example = [ "localhost.localdomain" "workinprogress.example.com" ];
+ description = ''
+ Additional entries to be appended to 127.0.0.1 entry in /etc/hosts.
+ '';
+ };
+
+
networking.extraHosts = lib.mkOption {
type = types.lines;
default = "";
example = "192.168.0.1 lanlocalhost";
description = ''
Additional entries to be appended to /etc/hosts.
+ Note that entries for 127.0.0.1 will not always work correctly if added from here.
+ They should be added via networking.extraLocalHosts.
'';
};
@@ -187,11 +199,11 @@ in
"rpc".source = pkgs.glibc.out + "/etc/rpc";
# /etc/hosts: Hostname-to-IP mappings.
- "hosts".text =
+ "hosts".text = let foo = concatStringsSep " " cfg.extraLocalHosts; in
''
- 127.0.0.1 localhost
+ 127.0.0.1 localhost ${foo}
${optionalString cfg.enableIPv6 ''
- ::1 localhost
+ ::1 localhost ${foo}
''}
${cfg.extraHosts}
'';