forked from Mirrors/nixos-infect
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.
This commit is contained in:
parent
914dad1039
commit
89b92f3de1
1 changed files with 8 additions and 3 deletions
11
nixos-infect
11
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
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue