2023-08-28 00:45:27 +02:00
|
|
|
{
|
|
|
|
liminix
|
|
|
|
, ifwait
|
|
|
|
, serviceFns
|
|
|
|
, lib
|
|
|
|
}:
|
2023-11-27 00:15:28 +01:00
|
|
|
{
|
|
|
|
ifname
|
|
|
|
, devpath ? null
|
|
|
|
, mtu} :
|
|
|
|
# if devpath is supplied, we rename the interface at that
|
|
|
|
# path to have the specified name.
|
2023-08-28 00:45:27 +02:00
|
|
|
let
|
|
|
|
inherit (liminix.services) longrun oneshot;
|
|
|
|
inherit (lib) concatStringsSep;
|
|
|
|
name = "${ifname}.link";
|
2023-11-27 00:15:28 +01:00
|
|
|
rename = if devpath != null
|
|
|
|
then ''
|
|
|
|
oldname=$(cd /sys${devpath} && cd net/ && echo *)
|
|
|
|
ip link set ''${oldname} name ${ifname}
|
|
|
|
''
|
|
|
|
else "";
|
2023-08-28 00:45:27 +02:00
|
|
|
in oneshot {
|
2023-11-27 00:15:28 +01:00
|
|
|
inherit name;
|
|
|
|
up = ''
|
|
|
|
${rename}
|
|
|
|
${liminix.networking.ifup name ifname}
|
|
|
|
'';
|
2023-08-28 00:45:27 +02:00
|
|
|
down = "ip link set down dev ${ifname}";
|
|
|
|
}
|