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 #36261
Conversation
/cc @peti |
nixos/modules/config/networking.nix
Outdated
@@ -213,6 +213,10 @@ in | |||
otherHosts = allToString ( removeAttrs cfg.hosts [ "127.0.0.1" "::1" ]); | |||
in | |||
'' | |||
127.0.0.1 ${cfg.hostName} |
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.
It should be possible to disable this behavior.
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.
any ideas for the disable config option name?
I added a new option, |
I'm not especially fond of that option name, though |
You shouldn't use "127.0.0.1" for that, see #1248 (comment). Other than that, I 👍 this. Should have been the default ages ago. |
Good spot, I've changed it to point at 127.0.1.1 now |
So kubernetes does not use nscd? |
@@ -213,6 +221,12 @@ in | |||
otherHosts = allToString ( removeAttrs cfg.hosts [ "127.0.0.1" "::1" ]); | |||
in | |||
'' | |||
${optionalString cfg.hostnameInHosts '' | |||
127.0.1.1 ${cfg.hostName} |
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.
Note that it can be empty: https://github.com/NixOS/nixpkgs/blob/release-17.09/nixos/modules/tasks/network-interfaces.nix#L326-L327
@kragniz ping! |
@danbst why would you want to set it to empty string, btw? |
@oxij See https://github.com/NixOS/nixpkgs/blob/release-18.03/nixos/modules/tasks/network-interfaces.nix#L374-L375
So technically someone may have used |
What's the status of this? It breaks i.e. RabbitMQ by default. |
If the OP won't come back to life till the end of the week I'll make an edited version and PR that.
|
I'll update this by the end of the week |
See #47241. |
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.
Closing: superseded by #47241 |
Motivation for this change
I'm testing some kubernetes related stuff, and it's assumed in a bunch of places that the hostname is resolvable. I could add this with
networking.extraHosts
, but I think it should be the default. See #1248 for some past discussion.Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)