diff options
author | Valentin Shirokov <regellosigkeitsaxiom@yandex.ru> | 2017-07-04 01:58:48 +0300 |
---|---|---|
committer | Valentin Shirokov <regellosigkeitsaxiom@yandex.ru> | 2017-07-04 02:19:11 +0300 |
commit | f9ec52dedceb3904b49c27d49076a881c43ba4cf (patch) | |
tree | 9468eb848642fd9e598e519a1672898e6973852e /nixos/modules/config/networking.nix | |
parent | c31d21c9b1b81cf78e08a85d298d3f09ddc7c0ae (diff) |
Added networking.extraLocalHosts option
It adds its contents to '127.0.0.1' line of /etc/hosts
It makes possible to point multiple domains to localhost in correct way
Diffstat (limited to 'nixos/modules/config/networking.nix')
-rw-r--r-- | nixos/modules/config/networking.nix | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/nixos/modules/config/networking.nix b/nixos/modules/config/networking.nix index d503f5a8b20e..ea9e8b712c68 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 <filename>/etc/hosts</filename>. + ''; + }; + + networking.extraHosts = lib.mkOption { type = types.lines; default = ""; example = "192.168.0.1 lanlocalhost"; description = '' Additional entries to be appended to <filename>/etc/hosts</filename>. + Note that entries for 127.0.0.1 will not always work correctly if added from here. + They should be added via <literal>networking.extraLocalHosts</literal>. ''; }; @@ -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} ''; |