From 89b92f3de13deb6dba728fe50a56ce234fbf3745 Mon Sep 17 00:00:00 2001 From: Danylo Hlynskyi Date: Thu, 12 Jul 2018 21:38:36 +0300 Subject: [PATCH] Fix hardcode of eth0 in several places The problem was that some VPS (from GigaCloud provider, Ukraine) provided `ens3` interface name, but after infection it was renamed to `eth0` via udev rules. --- nixos-infect | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nixos-infect b/nixos-infect index c7b5076..70b9bc8 100755 --- a/nixos-infect +++ b/nixos-infect @@ -67,9 +67,13 @@ EOF fi nameservers=($(grep ^nameserver /etc/resolv.conf | cut -f2 -d' ')) - + if [ "$eth0_name" = eth* ]; then + predictable_inames="usePredictableInterfaceNames = lib.mkForce false;" + else + predictable_inames="usePredictableInterfaceNames = lib.mkForce true;" + fi cat > /etc/nixos/networking.nix << EOF -{ ... }: { +{ lib, ... }: { # This file was populated at runtime with the networking # details gathered from the active system. networking = { @@ -79,6 +83,7 @@ EOF defaultGateway = "${gateway}"; defaultGateway6 = "${gateway6}"; dhcpcd.enable = false; + $predictable_inames interfaces = { $eth0_name = { ipv4.addresses = [$(for a in "${eth0_ip4s[@]}"; do echo -n " @@ -92,7 +97,7 @@ EOF }; }; services.udev.extraRules = '' - ATTR{address}=="${ether0}", NAME="eth0" + ATTR{address}=="${ether0}", NAME="${eth0_name}" $extraRules1 ''; }