From 46b7ddf402dd339c3ca20e4f35e082c4d77b6433 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 11 Feb 2013 16:01:01 +0100 Subject: [PATCH] Add option to disable predictable network interface naming --- modules/services/hardware/udev.nix | 26 +++++++++++++++++++++++--- modules/tasks/network-interfaces.nix | 1 + 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/modules/services/hardware/udev.nix b/modules/services/hardware/udev.nix index e1a338d6ad8b..f793b9387db1 100644 --- a/modules/services/hardware/udev.nix +++ b/modules/services/hardware/udev.nix @@ -37,8 +37,7 @@ let echo "Adding rules for package $i" for j in $i/{etc,lib}/udev/rules.d/*; do echo "Copying $j to $out/$(basename $j)" - echo "# Copied from $j" > $out/$(basename $j) - cat $j >> $out/$(basename $j) + cat $j > $out/$(basename $j) done done @@ -83,6 +82,10 @@ let for i in ${toString cfg.packages}; do grep -l '\(RUN+\|IMPORT{program}\)="\(/usr\)\?/s\?bin' $i/*/udev/rules.d/* || true done + + ${optionalString (!config.networking.usePredictableInterfaceNames) '' + ln -s /dev/null $out/80-net-name-slot.rules + ''} ''; # */ }; @@ -141,7 +144,7 @@ in example = '' KERNEL=="eth*", ATTR{address}=="00:1D:60:B9:6D:4F", NAME="my_fast_network_card" ''; - type = with pkgs.lib.types; string; + type = types.lines; description = '' Additional udev rules. They'll be written into file 10-local.rules. Thus they are @@ -176,6 +179,23 @@ in }; }; + networking.usePredictableInterfaceNames = mkOption { + default = true; + type = types.bool; + description = '' + Whether to assign predictable + names to network interfaces. If enabled, interfaces + are assigned names that contain topology information + (e.g. wlp3s0) and thus should be stable + across reboots. If disabled, names depend on the order in + which interfaces are discovered by the kernel, which may + change randomly across reboots; for instance, you may find + eth0 and eth1 flipping + unpredictably. + ''; + }; + }; diff --git a/modules/tasks/network-interfaces.nix b/modules/tasks/network-interfaces.nix index 49dd47251e5d..a31253ea4b02 100644 --- a/modules/tasks/network-interfaces.nix +++ b/modules/tasks/network-interfaces.nix @@ -228,6 +228,7 @@ in configured. ''; }; + };