liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

l2tp.nix (850B)


      1 {
      2   lib,
      3   liminix,
      4   output-template,
      5   serviceFns,
      6   svc,
      7   writeAshScript,
      8   writeText,
      9   xl2tpd,
     10   callPackage,
     11 }:
     12 {
     13   lns,
     14   ppp-options,
     15   lcpEcho,
     16   bandwidth,
     17   username,
     18   password,
     19   debug,
     20 }:
     21 let
     22   name = "${lns}.l2tp";
     23   common = callPackage ./common.nix { inherit svc; };
     24 
     25   conf = writeText "xl2tpd.conf" ''
     26     [lac upstream]
     27     lns = ${lns}
     28     require authentication = no
     29     pppoptfile = /run/${name}/ppp-options
     30     autodial = yes
     31     redial = yes
     32     redial timeout = 1
     33     max redials = 2 # this gives 1 actual retry, as xl2tpd can't count
     34   '';
     35   control = "/run/${name}/control";
     36 in
     37 common {
     38   inherit
     39     name
     40     debug
     41     username
     42     password
     43     lcpEcho
     44     bandwidth
     45     ppp-options
     46     ;
     47   command = ''
     48     touch ${control}
     49     exec ${xl2tpd}/bin/xl2tpd -D -p /run/${name}/${name}.pid -c ${conf} -C ${control} 
     50   '';
     51 }