summary refs log tree commit diff
path: root/modules/tasks
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-02-20 00:00:50 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-02-20 00:00:50 +0000
commita218a602d417c135b9265f253ea7d26bfa0367bc (patch)
treea785f4ee2b8021d4a55dc3d0fb6025462dae6ede /modules/tasks
parent1707d1130f0129eee2fbf24a88520359dba18c73 (diff)
downloadnixpkgs-a218a602d417c135b9265f253ea7d26bfa0367bc.tar
nixpkgs-a218a602d417c135b9265f253ea7d26bfa0367bc.tar.gz
nixpkgs-a218a602d417c135b9265f253ea7d26bfa0367bc.tar.bz2
nixpkgs-a218a602d417c135b9265f253ea7d26bfa0367bc.tar.lz
nixpkgs-a218a602d417c135b9265f253ea7d26bfa0367bc.tar.xz
nixpkgs-a218a602d417c135b9265f253ea7d26bfa0367bc.tar.zst
nixpkgs-a218a602d417c135b9265f253ea7d26bfa0367bc.zip
* 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
Diffstat (limited to 'modules/tasks')
-rw-r--r--modules/tasks/network-interfaces.nix21
1 files changed, 11 insertions, 10 deletions
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 <<EOF
+            ${optionalString (cfg.nameservers != [] && cfg.domain != "") ''
+              domain ${cfg.domain}
+            ''}
+            ${flip concatMapStrings cfg.nameservers (ns: ''
+              nameserver ${ns}
+            '')}
+            EOF
 
             # Set the default gateway.
             ${optionalString (cfg.defaultGateway != "") ''