liminix

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

default.nix (4684B)


      1 ## PPP
      2 ## ===
      3 ##
      4 ## ``ppoe`` (PPP over Ethernet) provides a service to address the case
      5 ## where your Liminix device is connected to an upstream network using
      6 ## PPPoE. This is typical for UK broadband connections where the
      7 ## physical connection is made by OpenReach ("Fibre To The X") and
      8 ## common in some other localities as well: check with your ISP if this is
      9 ## you.
     10 ##
     11 ## ``l2tp`` (Layer 2 Tunelling Protocol) provides a service that
     12 ## tunnels PPP over the Internet.  This may be used by some ISPs in
     13 ## conjunction with a DHCP uplink, or other more creative forms of
     14 ## network connection
     15 
     16 {
     17   lib,
     18   pkgs,
     19   config,
     20   ...
     21 }:
     22 let
     23   inherit (lib) mkOption types;
     24   inherit (pkgs) liminix;
     25 in
     26 {
     27   imports = [ ../secrets ];
     28   options = {
     29     system.service.pppoe = mkOption {
     30       type = liminix.lib.types.serviceDefn;
     31     };
     32     system.service.l2tp = mkOption {
     33       type = liminix.lib.types.serviceDefn;
     34     };
     35   };
     36   config = {
     37     system.service.pppoe = config.system.callService ./pppoe.nix {
     38       interface = mkOption {
     39         type = liminix.lib.types.service;
     40         description = "ethernet interface to run PPPoE over";
     41       };
     42       username = mkOption {
     43         type = types.nullOr (liminix.lib.types.replacable types.str);
     44         default = null;
     45         description = "username";
     46       };
     47       password = mkOption {
     48         type = types.nullOr (liminix.lib.types.replacable types.str);
     49         default = null;
     50         description = "password";
     51       };
     52       bandwidth = mkOption {
     53         type = types.nullOr (types.int);
     54         default = null;
     55         description = "approximate bandwidth in bytes/second. Used to calculate rate limits for ICMP";
     56       };
     57       lcpEcho = {
     58         adaptive = mkOption {
     59           description = "send LCP echo-request frames only if no traffic was received from the peer since the last echo-request was sent";
     60           type = types.bool;
     61           default = true;
     62         };
     63         interval = mkOption {
     64           type = types.nullOr types.int;
     65           default = 3;
     66           description = "send an LCP echo-request frame to the peer every n seconds";
     67         };
     68         failure = mkOption {
     69           type = types.nullOr types.int;
     70           default = 3;
     71           description = "terminate connection if n LCP echo-requests are sent without receiving a valid LCP echo-reply";
     72         };
     73       };
     74       debug = mkOption {
     75         description = "log the contents of all control packets sent or received";
     76         default = false;
     77         type = types.bool;
     78       };
     79       ppp-options = mkOption {
     80         type = types.listOf types.str;
     81         description = "options supplied on ppp command line";
     82         default = [ ];
     83       };
     84     };
     85     system.service.l2tp = config.system.callService ./l2tp.nix {
     86       lns = mkOption {
     87         type = types.str;
     88         description = "hostname or address of the L2TP network server";
     89       };
     90       username = mkOption {
     91         type = types.nullOr (liminix.lib.types.replacable types.str);
     92         default = null;
     93         description = "username";
     94       };
     95       password = mkOption {
     96         type = types.nullOr (liminix.lib.types.replacable types.str);
     97         default = null;
     98         description = "password";
     99       };
    100       lcpEcho = {
    101         adaptive = mkOption {
    102           description = "send LCP echo-request frames only if no traffic was received from the peer since the last echo-request was sent";
    103           type = types.bool;
    104           default = true;
    105         };
    106         interval = mkOption {
    107           type = types.nullOr types.int;
    108           default = 3;
    109           description = "send an LCP echo-request frame to the peer every n seconds";
    110         };
    111         failure = mkOption {
    112           type = types.nullOr types.int;
    113           default = 3;
    114           description = "terminate connection if n LCP echo-requests are sent without receiving a valid LCP echo-reply";
    115         };
    116       };
    117       debug = mkOption {
    118         description = "log the contents of all control packets sent or received";
    119         default = false;
    120         type = types.bool;
    121       };
    122       ppp-options = mkOption {
    123         type = types.listOf types.str;
    124         default = [ ];
    125         description = "options supplied on ppp command line";
    126       };
    127     };
    128 
    129     # rp-pppoe attempts to drop privs by switching to user "nobody"
    130     users.nobody = {
    131       uid = 65534;
    132       gid = 65534;
    133       gecos = "Captain Nemo";
    134       dir = "/run/";
    135       shell = "/bin/false";
    136     };
    137 
    138     kernel = {
    139       config = {
    140         PPP = "y";
    141         PPP_BSDCOMP = "y";
    142         PPP_DEFLATE = "y";
    143         PPP_ASYNC = "y";
    144         PPP_SYNC_TTY = "y";
    145         PPPOL2TP = "y";
    146         L2TP = "y";
    147       };
    148     };
    149   };
    150 }