1
0
liminix/modules/dhcp6c/client.nix
Daniel Barlow 53c6d506cf dhcp6c subscribe to ppp ifindex
when the peer bounces ppp, s6 will restart the ppp process but not
restart the dependent services (because the service isn't considered
to have gone down)

so the dependent services need to notice when the outputs from ppp
have changed
2025-03-31 23:15:28 +01:00

31 lines
780 B
Nix

{
liminix,
odhcp6c,
odhcp-script,
svc
}:
{ interface }:
let
inherit (liminix.services) longrun;
inherit (liminix) outputRef;
name = "dhcp6c.${interface.name}";
service =
longrun {
inherit name;
notification-fd = 10;
run = ''
export SERVICE_STATE=$SERVICE_OUTPUTS/${name}
ifname=$(output ${interface} ifname)
test -n "$ifname" && ${odhcp6c}/bin/odhcp6c -s ${odhcp-script} -e -v -p /run/${name}.pid -P0 $ifname
)
'';
dependencies = [ interface ];
};
in svc.secrets.subscriber.build {
# if the ppp service gets restarted, the interface may be different and
# we will have to restart dhcp on the new one
watch = [ (outputRef interface "ifindex") ];
action = "restart";
inherit service;
}