From a218a602d417c135b9265f253ea7d26bfa0367bc Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 20 Feb 2012 00:00:50 +0000 Subject: [PATCH] * Use openresolv to set the static nameserver configuration. Next step is to get the DHCP client, OpenVPN etc. to use openresolv as well. svn path=/nixos/trunk/; revision=32411 --- modules/system/boot/stage-2-init.sh | 1 + modules/tasks/network-interfaces.nix | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/system/boot/stage-2-init.sh b/modules/system/boot/stage-2-init.sh index 10165049046..452e3c99477 100644 --- a/modules/system/boot/stage-2-init.sh +++ b/modules/system/boot/stage-2-init.sh @@ -96,6 +96,7 @@ mkdir -m 0755 -p /etc/nixos # Miscellaneous boot time cleanup. rm -rf /var/run /var/lock /var/log/upstart +rm -f /etc/resolv.conf #echo -n "cleaning \`/tmp'..." #rm -rf --one-file-system /tmp/* diff --git a/modules/tasks/network-interfaces.nix b/modules/tasks/network-interfaces.nix index 27ca840ecdb..e13fbff0ce6 100644 --- a/modules/tasks/network-interfaces.nix +++ b/modules/tasks/network-interfaces.nix @@ -179,6 +179,7 @@ in pkgs.nettools pkgs.wirelesstools pkgs.rfkill + pkgs.openresolv ] ++ optional (cfg.bridges != {}) pkgs.bridge_utils ++ optional cfg.enableIPv6 pkgs.ndisc6; @@ -196,6 +197,7 @@ in '' set +e # continue in case of errors + # Set MAC addresses of interfaces, if desired. ${flip concatMapStrings cfg.interfaces (i: optionalString (i.macAddress != "") '' @@ -236,16 +238,15 @@ in '') } - # Set the nameservers. - if test -n "${toString cfg.nameservers}"; then - rm -f /etc/resolv.conf - if test -n "${cfg.domain}"; then - echo "domain ${cfg.domain}" >> /etc/resolv.conf - fi - for i in ${toString cfg.nameservers}; do - echo "nameserver $i" >> /etc/resolv.conf - done - fi + # Set the static DNS configuration, if given. + cat | ${pkgs.openresolv}/sbin/resolvconf -a static <