summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-04-18 19:34:45 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-04-18 19:34:45 +0200
commit232a9caa9680db0d084504a43c334e2e583a8cd9 (patch)
tree4c7afa5d58eda9563e21e84aee95c70f11ee290c /nixos/modules
parent465d6ff5722cf1c9b7e58793ed50c5bc750c5098 (diff)
downloadnixlib-232a9caa9680db0d084504a43c334e2e583a8cd9.tar
nixlib-232a9caa9680db0d084504a43c334e2e583a8cd9.tar.gz
nixlib-232a9caa9680db0d084504a43c334e2e583a8cd9.tar.bz2
nixlib-232a9caa9680db0d084504a43c334e2e583a8cd9.tar.lz
nixlib-232a9caa9680db0d084504a43c334e2e583a8cd9.tar.xz
nixlib-232a9caa9680db0d084504a43c334e2e583a8cd9.tar.zst
nixlib-232a9caa9680db0d084504a43c334e2e583a8cd9.zip
Fix predictable network interface naming
In current systemd, this has been moved to systemd-network, which
we're not using yet. So revive the old udev rules from systemd 203.
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/services/hardware/80-net-name-slot.rules13
-rw-r--r--nixos/modules/services/hardware/udev.nix4
2 files changed, 15 insertions, 2 deletions
diff --git a/nixos/modules/services/hardware/80-net-name-slot.rules b/nixos/modules/services/hardware/80-net-name-slot.rules
new file mode 100644
index 000000000000..18547f170a3f
--- /dev/null
+++ b/nixos/modules/services/hardware/80-net-name-slot.rules
@@ -0,0 +1,13 @@
+# Copied from systemd 203.
+ACTION=="remove", GOTO="net_name_slot_end"
+SUBSYSTEM!="net", GOTO="net_name_slot_end"
+NAME!="", GOTO="net_name_slot_end"
+
+IMPORT{cmdline}="net.ifnames"
+ENV{net.ifnames}=="0", GOTO="net_name_slot_end"
+
+NAME=="", ENV{ID_NET_NAME_ONBOARD}!="", NAME="$env{ID_NET_NAME_ONBOARD}"
+NAME=="", ENV{ID_NET_NAME_SLOT}!="", NAME="$env{ID_NET_NAME_SLOT}"
+NAME=="", ENV{ID_NET_NAME_PATH}!="", NAME="$env{ID_NET_NAME_PATH}"
+
+LABEL="net_name_slot_end"
diff --git a/nixos/modules/services/hardware/udev.nix b/nixos/modules/services/hardware/udev.nix
index 169a2e884147..507752dabcf7 100644
--- a/nixos/modules/services/hardware/udev.nix
+++ b/nixos/modules/services/hardware/udev.nix
@@ -83,8 +83,8 @@ let
         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
+      ${optionalString config.networking.usePredictableInterfaceNames ''
+        cp ${./80-net-name-slot.rules} $out/80-net-name-slot.rules
       ''}
 
       # If auto-configuration is disabled, then remove