liminix

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

default.nix (4828B)


      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   mkStringOption =
     26     description:
     27     mkOption {
     28       type = types.nullOr types.str;
     29       default = null;
     30       inherit description;
     31     };
     32 in
     33 {
     34   imports = [ ../secrets ];
     35   options = {
     36     system.service.pppoe = mkOption {
     37       type = liminix.lib.types.serviceDefn;
     38     };
     39     system.service.l2tp = mkOption {
     40       type = liminix.lib.types.serviceDefn;
     41     };
     42   };
     43   config = {
     44     system.service.pppoe = config.system.callService ./pppoe.nix {
     45       interface = mkOption {
     46         type = liminix.lib.types.service;
     47         description = "ethernet interface to run PPPoE over";
     48       };
     49       username = mkOption {
     50         type = types.nullOr (liminix.lib.types.replacable types.str);
     51         default = null;
     52         description = "username";
     53       };
     54       password = mkOption {
     55         type = types.nullOr (liminix.lib.types.replacable types.str);
     56         default = null;
     57         description = "password";
     58       };
     59       bandwidth = mkOption {
     60         type = types.nullOr (types.int);
     61         default = null;
     62         description = "approximate bandwidth in bytes/second. Used to calculate rate limits for ICMP";
     63       };
     64       lcpEcho = {
     65         adaptive = mkOption {
     66           description = "send LCP echo-request frames only if no traffic was received from the peer since the last echo-request was sent";
     67           type = types.bool;
     68           default = true;
     69         };
     70         interval = mkOption {
     71           type = types.nullOr types.int;
     72           default = 3;
     73           description = "send an LCP echo-request frame to the peer every n seconds";
     74         };
     75         failure = mkOption {
     76           type = types.nullOr types.int;
     77           default = 3;
     78           description = "terminate connection if n LCP echo-requests are sent without receiving a valid LCP echo-reply";
     79         };
     80       };
     81       debug = mkOption {
     82         description = "log the contents of all control packets sent or received";
     83         default = false;
     84         type = types.bool;
     85       };
     86       ppp-options = mkOption {
     87         type = types.listOf types.str;
     88         description = "options supplied on ppp command line";
     89         default = [ ];
     90       };
     91     };
     92     system.service.l2tp = config.system.callService ./l2tp.nix {
     93       lns = mkOption {
     94         type = types.str;
     95         description = "hostname or address of the L2TP network server";
     96       };
     97       username = mkOption {
     98         type = types.nullOr (liminix.lib.types.replacable types.str);
     99         default = null;
    100         description = "username";
    101       };
    102       password = mkOption {
    103         type = types.nullOr (liminix.lib.types.replacable types.str);
    104         default = null;
    105         description = "password";
    106       };
    107       lcpEcho = {
    108         adaptive = mkOption {
    109           description = "send LCP echo-request frames only if no traffic was received from the peer since the last echo-request was sent";
    110           type = types.bool;
    111           default = true;
    112         };
    113         interval = mkOption {
    114           type = types.nullOr types.int;
    115           default = 3;
    116           description = "send an LCP echo-request frame to the peer every n seconds";
    117         };
    118         failure = mkOption {
    119           type = types.nullOr types.int;
    120           default = 3;
    121           description = "terminate connection if n LCP echo-requests are sent without receiving a valid LCP echo-reply";
    122         };
    123       };
    124       debug = mkOption {
    125         description = "log the contents of all control packets sent or received";
    126         default = false;
    127         type = types.bool;
    128       };
    129       ppp-options = mkOption {
    130         type = types.listOf types.str;
    131         default = [ ];
    132         description = "options supplied on ppp command line";
    133       };
    134     };
    135 
    136     # rp-pppoe attempts to drop privs by switching to user "nobody"
    137     users.nobody = {
    138       uid = 65534;
    139       gid = 65534;
    140       gecos = "Captain Nemo";
    141       dir = "/run/";
    142       shell = "/bin/false";
    143     };
    144 
    145     kernel = {
    146       config = {
    147         PPP = "y";
    148         PPP_BSDCOMP = "y";
    149         PPP_DEFLATE = "y";
    150         PPP_ASYNC = "y";
    151         PPP_SYNC_TTY = "y";
    152         PPPOL2TP = "y";
    153         L2TP = "y";
    154       };
    155     };
    156   };
    157 }