2023-09-24 22:29:30 +00:00
|
|
|
{
|
2025-02-10 21:55:08 +00:00
|
|
|
liminix,
|
|
|
|
odhcp6c,
|
|
|
|
odhcp-script,
|
2025-03-31 22:15:28 +00:00
|
|
|
svc
|
2023-09-24 22:29:30 +00:00
|
|
|
}:
|
2025-02-10 21:55:08 +00:00
|
|
|
{ interface }:
|
2023-09-24 22:29:30 +00:00
|
|
|
let
|
|
|
|
inherit (liminix.services) longrun;
|
2025-03-31 22:15:28 +00:00
|
|
|
inherit (liminix) outputRef;
|
2023-09-24 22:29:30 +00:00
|
|
|
name = "dhcp6c.${interface.name}";
|
2025-03-31 22:15:28 +00:00
|
|
|
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
|
|
|
}
|