540a1dfd76
build-time uses can mostly be replaced with interface.name for runtime uses, switch to $(output ${interface} name)
51 lines
1 KiB
Nix
51 lines
1 KiB
Nix
{
|
|
liminix
|
|
, lib
|
|
, ppp
|
|
, pppoe
|
|
, writeAshScript
|
|
, serviceFns
|
|
} :
|
|
{ interface, ppp-options }:
|
|
let
|
|
inherit (liminix.services) longrun;
|
|
name = "${interface.name}.pppoe";
|
|
ip-up = writeAshScript "ip-up" {} ''
|
|
. ${serviceFns}
|
|
(in_outputs ${name}
|
|
echo $1 > ifname
|
|
echo $2 > tty
|
|
echo $3 > speed
|
|
echo $4 > address
|
|
echo $5 > peer-address
|
|
echo $DNS1 > ns1
|
|
echo $DNS2 > ns2
|
|
)
|
|
echo >/proc/self/fd/10
|
|
'';
|
|
ip6-up = writeAshScript "ip6-up" {} ''
|
|
. ${serviceFns}
|
|
(in_outputs ${name}
|
|
echo $4 > ipv6-address
|
|
echo $5 > ipv6-peer-address
|
|
)
|
|
echo >/proc/self/fd/10
|
|
'';
|
|
ppp-options' = ppp-options ++ [
|
|
"ip-up-script" ip-up
|
|
"ipv6-up-script" ip6-up
|
|
"ipparam" name
|
|
"nodetach"
|
|
"usepeerdns"
|
|
"logfd" "2"
|
|
];
|
|
in
|
|
longrun {
|
|
inherit name;
|
|
run = ''
|
|
. ${serviceFns}
|
|
${ppp}/bin/pppd pty "${pppoe}/bin/pppoe -I $(output ${interface} ifname)" ${lib.concatStringsSep " " ppp-options'}
|
|
'';
|
|
notification-fd = 10;
|
|
dependencies = [ interface ];
|
|
}
|