address.nix (779B)
1 { 2 liminix 3 , ifwait 4 , serviceFns 5 , lib 6 }: 7 {interface, family, address, prefixLength} : 8 let 9 inherit (liminix.services) oneshot; 10 # rather depending on the assumption that nobody will 11 # ever add two addresses which are the same but with different 12 # prefixes, or the same but different protocols 13 name = "${interface.name}.a.${address}"; 14 up = '' 15 . ${serviceFns} 16 dev=$(output ${interface} ifname) 17 ip address add ${address}/${toString prefixLength} dev $dev 18 (in_outputs ${name} 19 echo ${address} > address 20 echo ${toString prefixLength} > prefix-length 21 echo ${family} > family 22 echo $dev > ifname 23 ) 24 ''; 25 in oneshot { 26 inherit name up; 27 down = "true"; # this has been broken for ~ ages 28 dependencies = [ interface ]; 29 }