link.nix (706B)
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 ( cd /proc/sys/net/ipv6/conf/${ifname} 29 ${ 30 liminix.writeSysctls { 31 autoconf = 0; 32 accept_ra = 0; 33 } 34 } ) 35 ${liminix.networking.ifup name ifname} 36 ''; 37 down = "ip link set down dev ${ifname}"; 38 }