liminix/modules/ppp/l2tp.nix

41 lines
791 B
Nix
Raw Normal View History

2024-05-11 21:48:06 +00:00
{
2024-09-03 21:57:45 +00:00
lib,
liminix,
output-template,
serviceFns,
svc,
writeAshScript,
writeText,
xl2tpd,
2024-09-03 23:12:26 +00:00
callPackage
2024-05-11 21:48:06 +00:00
} :
{ lns,
ppp-options,
lcpEcho,
username,
password,
debug
}:
2024-05-11 21:48:06 +00:00
let
name = "${lns}.l2tp";
2024-09-03 23:12:26 +00:00
common = callPackage ./common.nix { inherit svc; };
2024-05-11 21:48:06 +00:00
conf = writeText "xl2tpd.conf" ''
[lac upstream]
lns = ${lns}
require authentication = no
pppoptfile = /run/${name}/ppp-options
2024-05-11 21:48:06 +00:00
autodial = yes
redial = yes
redial timeout = 1
max redials = 2 # this gives 1 actual retry, as xl2tpd can't count
2024-05-11 21:48:06 +00:00
'';
control = "/run/${name}/control";
2024-09-03 23:12:26 +00:00
in common {
inherit name debug username password lcpEcho ppp-options;
command = ''
touch ${control}
exec ${xl2tpd}/bin/xl2tpd -D -p /run/${name}/${name}.pid -c ${conf} -C ${control}
'';
2024-05-11 21:48:06 +00:00
}