liminix/modules/network/link.nix
sinavir b129f775b2
All checks were successful
build liminix / build_vm_qemu_mips (pull_request) Successful in 35s
build liminix / build_zyxel-nwa50ax_mips (pull_request) Successful in 38s
build liminix / test_shell_customization (pull_request) Successful in 42s
build liminix / test_hostapd (pull_request) Successful in 45s
feat(networking): Add wlan mac personalisation
2025-02-04 22:00:13 +01:00

31 lines
647 B
Nix

{
liminix
, ifwait
, serviceFns
, lib
}:
{
ifname
, devpath ? null
, mac ? 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";
rename = if devpath != null
then ''
oldname=$(cd /sys${devpath} && cd net/ && echo *)
ip link set ''${oldname} name ${ifname}
''
else "";
in oneshot {
inherit name;
up = ''
${rename}
${liminix.networking.ifup name ifname mac}
'';
down = "ip link set down dev ${ifname}";
}