convert network link/address to module-based-service
... and make bridge use it. We also had to convert bridge back into a pair of services. Downstreams want to depend on the bridge it self being configured even if not necessarily all the members are up. e.g. don't want to break ssh on lan if there's a misconfigured wlan device
This commit is contained in:
29
modules/network/address.nix
Normal file
29
modules/network/address.nix
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
liminix
|
||||
, ifwait
|
||||
, serviceFns
|
||||
, lib
|
||||
}:
|
||||
{interface, family, address, prefixLength} :
|
||||
let
|
||||
inherit (liminix.services) oneshot;
|
||||
# rather depending on the assumption that nobody will
|
||||
# ever add two addresses which are the same but with different
|
||||
# prefixes, or the same but different protocols
|
||||
name = "${interface.name}.a.${address}";
|
||||
up = ''
|
||||
. ${serviceFns}
|
||||
dev=$(output ${interface} ifname)
|
||||
ip address add ${address}/${toString prefixLength} dev $dev
|
||||
(in_outputs ${name}
|
||||
echo ${address} > address
|
||||
echo ${toString prefixLength} > prefix-length
|
||||
echo ${family} > family
|
||||
echo $dev > ifname
|
||||
)
|
||||
'';
|
||||
in oneshot {
|
||||
inherit name up;
|
||||
down = "true"; # this has been broken for ~ ages
|
||||
dependencies = [ interface ];
|
||||
}
|
Reference in New Issue
Block a user