New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/networking: add hostname to /etc/hosts by default, simplify #47241
nixos/networking: add hostname to /etc/hosts by default, simplify #47241
Conversation
Did you mean
```networking.hosts = lib.mkOptionDefault { ...```
No, this is intended. Any non-default priority will break configs that set `networking.hosts` directly without priority qualifiers. (Which, I expect, most do.)
With my version both
```
networking.hosts = {
...
};
```
and
```
networking.hosts = mkForce {
...
};
```
work exactly as before.
I'd order all IPv4 before IPv6 (or IPv6 before IPv4, it does not matter) instead of current alphanumeric string sort.
...
I see, but note that the same issue applies to `master`.
This implementation changes nothing in this regard in the most common use case because digits are `<` than ":" in ASCII order, hence this produces the same `/etc/hosts` as before (+ "127.0.1.1" when `hostName` is not empty).
This can only be an issue if you explicitly add non-zero prefixed IPv6 addresses to `networking.hosts`.
(It might worth a separate issue/PR...)
In that sense I agree, if that's an actual issue, we can split `cfg.hosts` into IPv4 and IPv6 parts in a separate PR.
|
This can make localhost not in top of /etc/hosts:
Then Probably add assert and warning that forbids redefining localhost in |
Nah, mkBefore/mkAfter don't work here
result is
|
localhost can resolve to something other than 127.0.0.1
Right, I didn't think about that.
Probably add assert and warning that forbids redefining localhost in `networking.hosts`?
Right, `assert` seems the best option. Will do.
|
2434e18
to
f3362dc
Compare
Added the asserts. |
nixos/modules/config/networking.nix
Outdated
message = '' | ||
`networking.hosts` maps a non-loopback address to `localhost`. Generated | ||
`/etc/hosts` might make `localhost` resolve to that non-loopback address instead | ||
of `127.0.0.1` and `::1` which would break some applications. Please use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message should be simplified. It is also not very correct, because one may map "127.0.0.2" to localhost and it would be perfectly correct mapping
This message should be simplified.
Please suggest a better one. This is the best I managed.
It is also not very correct, because one may map "127.0.0.2" to localhost and it would be perfectly correct mapping
But I expect some applications to break with that too.
|
Maybe
|
Since `networking.hosts` is properly typed all of that magic `/etc/hosts` generator does can be dropped. People that disagree with the value of `networking.hosts` can simply `mkForce`.
We use `127.0.1.1` instead of `127.0.0.1` because some applications will fail if `127.0.0.1` resolves to something other than `localhost`. Debian does the same. See NixOS#1248 and NixOS#36261.
f3362dc
to
c578924
Compare
Done. |
ping!
|
@GrahamcOfBorg eval |
So by no means a problem with this PR but I wanted to note that this broke my dnsmasq configuration. The server that had dnsmasq running would return its ip address along with |
Motivation for this change
#1248 and #36261. This is an alternative simpler implementation of #36261.
Since
networking.hosts
is properly typed all of that magic/etc/hosts
generator does onmaster
can be dropped. People that disagree with the value ofnetworking.hosts
can simplymkForce
.Things done
Do not merge before 2018-09-30.