link.nix (554B)
1 { 2 liminix, 3 lib, 4 }: 5 { 6 ifname, 7 devpath ? null, 8 mtu, 9 }: 10 # if devpath is supplied, we rename the interface at that 11 # path to have the specified name. 12 let 13 inherit (liminix.services) oneshot; 14 name = "${ifname}.link"; 15 rename = 16 if devpath != null then 17 '' 18 oldname=$(cd /sys${devpath} && cd net/ && echo *) 19 ip link set ''${oldname} name ${ifname} 20 '' 21 else 22 ""; 23 in 24 oneshot { 25 inherit name; 26 up = '' 27 ${rename} 28 ${liminix.networking.ifup name ifname} 29 ''; 30 down = "ip link set down dev ${ifname}"; 31 }