support setting network device names
this means that net devices in devices/foo/default.nix can be specified by their sysfs paths (instead of by "eth0" and "eth1" that may change from one kernel version to the next) and given mnenomic names that are helpful for the hardware. Like "wan" and "lan[1..4]"
This commit is contained in:
@@ -4,13 +4,27 @@
|
||||
, serviceFns
|
||||
, lib
|
||||
}:
|
||||
{ifname, mtu} :
|
||||
{
|
||||
ifname
|
||||
, devpath ? null
|
||||
, mtu} :
|
||||
# if devpath is supplied, we rename the interface at that
|
||||
# path to have the specified name.
|
||||
let
|
||||
inherit (liminix.services) longrun oneshot;
|
||||
inherit (lib) concatStringsSep;
|
||||
name = "${ifname}.link";
|
||||
up = liminix.networking.ifup name ifname;
|
||||
rename = if devpath != null
|
||||
then ''
|
||||
oldname=$(cd /sys${devpath} && cd net/ && echo *)
|
||||
ip link set ''${oldname} name ${ifname}
|
||||
''
|
||||
else "";
|
||||
in oneshot {
|
||||
inherit name up;
|
||||
inherit name;
|
||||
up = ''
|
||||
${rename}
|
||||
${liminix.networking.ifup name ifname}
|
||||
'';
|
||||
down = "ip link set down dev ${ifname}";
|
||||
}
|
||||
|
Reference in New Issue
Block a user