Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 25c762f2bcca
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8177561e8f24
Choose a head ref
  • 9 commits
  • 1 file changed
  • 2 contributors

Commits on Jul 3, 2017

  1. 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
    regellosigkeitsaxiom committed Jul 3, 2017
    Copy the full SHA
    f9ec52d View commit details

Commits on Jul 8, 2017

  1. Copy the full SHA
    5f2826f View commit details
  2. Typo fix

    regellosigkeitsaxiom committed Jul 8, 2017
    Copy the full SHA
    ca54c3f View commit details
  3. Style adjustments

    Also dangerous typo fix
    regellosigkeitsaxiom committed Jul 8, 2017
    Copy the full SHA
    396db64 View commit details
  4. Copy the full SHA
    2f97993 View commit details

Commits on Jul 9, 2017

  1. Copy the full SHA
    1633938 View commit details
  2. Copy the full SHA
    d29fc73 View commit details

Commits on Jul 27, 2017

  1. Copy the full SHA
    635ecd8 View commit details

Commits on Jul 30, 2017

  1. 2
    Copy the full SHA
    8177561 View commit details
Showing with 41 additions and 3 deletions.
  1. +41 −3 nixos/modules/config/networking.nix
44 changes: 41 additions & 3 deletions nixos/modules/config/networking.nix
Original file line number Diff line number Diff line change
@@ -20,12 +20,35 @@ in

options = {

networking.fqdn = lib.mkOption {
type = types.nullOr types.str;
default = null;
example = "foo.example.com";
description = ''
Fully qualified domain name, if any.
'';
};

networking.hosts = lib.mkOption {
type = types.attrsOf ( types.listOf types.str );
default = {};
example = literalExample ''
{
"127.0.0.1" = [ "foo.bar.baz" ];
"192.168.0.2" = [ "fileserver.local" "nameserver.local" ];
};
'';
description = ''
Locally defined maps of hostnames to IP addresses.
'';
};

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>.
Additional verbatim entries to be appended to <filename>/etc/hosts</filename>.
'';
};

@@ -176,6 +199,9 @@ in

config = {

warnings = optional (cfg.extraHosts != "")
"networking.extraHosts is deprecated, please use networking.hosts instead";

environment.etc =
{ # /etc/services: TCP/UDP port assignments.
"services".source = pkgs.iana-etc + "/etc/services";
@@ -188,11 +214,23 @@ in

# /etc/hosts: Hostname-to-IP mappings.
"hosts".text =
let oneToString = set : ip : ip + " " + concatStringsSep " " ( getAttr ip set );
allToString = set : concatMapStringsSep "\n" ( oneToString set ) ( attrNames set );
userLocalHosts = optionalString
( builtins.hasAttr "127.0.0.1" cfg.hosts )
( concatStringsSep " " ( remove "localhost" cfg.hosts."127.0.0.1" ));
userLocalHosts6 = optionalString
( builtins.hasAttr "::1" cfg.hosts )
( concatStringsSep " " ( remove "localhost" cfg.hosts."::1" ));
otherHosts = allToString ( removeAttrs cfg.hosts [ "127.0.0.1" "::1" ]);
maybeFQDN = optionalString ( cfg.fqdn != null ) cfg.fqdn;
in
''
127.0.0.1 localhost
127.0.0.1 ${maybeFQDN} ${userLocalHosts} localhost
${optionalString cfg.enableIPv6 ''
::1 localhost
::1 ${maybeFQDN} ${userLocalHosts6} localhost
''}
${otherHosts}
${cfg.extraHosts}
'';