1
0
liminix/modules/dhcp6c/client.nix

31 lines
780 B
Nix
Raw Normal View History

2023-09-24 22:29:30 +00:00
{
liminix,
odhcp6c,
odhcp-script,
svc
2023-09-24 22:29:30 +00:00
}:
{ interface }:
2023-09-24 22:29:30 +00:00
let
inherit (liminix.services) longrun;
inherit (liminix) outputRef;
2023-09-24 22:29:30 +00:00
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;
2023-09-24 22:29:30 +00:00
}