Author: eelco
Date: Mon Feb 20 00:00:50 2012
New Revision: 32411
URL: https://nixos.org/websvn/nix/?rev=32411&sc=1
Log:
* Use openresolv to set the static nameserver configuration. Next
step is to get the DHCP client, OpenVPN etc. to use openresolv as
well.
Modified:
nixos/trunk/modules/system/boot/stage-2-init.sh
nixos/trunk/modules/tasks/network-interfaces.nix
Modified: nixos/trunk/modules/system/boot/stage-2-init.sh
==============================================================================
--- nixos/trunk/modules/system/boot/stage-2-init.sh Sun Feb 19 23:32:43
2012 (r32410)
+++ nixos/trunk/modules/system/boot/stage-2-init.sh Mon Feb 20 00:00:50
2012 (r32411)
@@ -96,6 +96,7 @@
# 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/*
Modified: nixos/trunk/modules/tasks/network-interfaces.nix
==============================================================================
--- nixos/trunk/modules/tasks/network-interfaces.nix Sun Feb 19 23:32:43
2012 (r32410)
+++ nixos/trunk/modules/tasks/network-interfaces.nix Mon Feb 20 00:00:50
2012 (r32411)
@@ -179,6 +179,7 @@
pkgs.nettools
pkgs.wirelesstools
pkgs.rfkill
+ pkgs.openresolv
]
++ optional (cfg.bridges != {}) pkgs.bridge_utils
++ optional cfg.enableIPv6 pkgs.ndisc6;
@@ -196,6 +197,7 @@
''
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 @@
'')
}
- # 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 != "") ''
_______________________________________________
nix-commits mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-commits