Skip to content
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/containers: Enable use of the network.useHostResolvConf option #34354

Merged
merged 1 commit into from Jan 28, 2018

Conversation

yesbox
Copy link
Contributor

@yesbox yesbox commented Jan 28, 2018

Motivation for this change

Currently containers.<name>.networking.useHostResolvConf = false; can never be set as it's in conflict with the true value in container-config.nix. This PR enables setting the option to false.

/etc/resolv.conf from the host will still always be copied. nspawn does this only when private networking is not enabled but NixOS does it unconditionally.

cp --remove-destination /etc/resolv.conf "$root/etc/resolv.conf"

Therefore useHostResolvConf=false relies on resolvconf to overwrite /etc/resolv.conf in the container.

# Use /etc/resolv.conf supplied by systemd-nspawn, if applicable.
if [ -n "@useHostResolvConf@" ] && [ -e /etc/resolv.conf ]; then
resolvconf -m 1000 -a host </etc/resolv.conf
fi

# Set the static DNS configuration, if given.
${pkgs.openresolv}/sbin/resolvconf -m 1 -a static <<EOF
${optionalString (cfg.nameservers != [] && cfg.domain != null) ''
domain ${cfg.domain}
''}

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@fpletz fpletz changed the title Enable use of the network.useHostResolvConf option nixos/containers: Enable use of the network.useHostResolvConf option Jan 28, 2018
@fpletz fpletz merged commit 2b270c1 into NixOS:master Jan 28, 2018
@fpletz
Copy link
Member

fpletz commented Jan 28, 2018

Thanks!

@yesbox yesbox deleted the optional_host_resolvconf branch February 4, 2018 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants