liminix

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

default.nix (1515B)


      1 ## Bridge module
      2 ## =============
      3 ##
      4 ##  Allows creation of Layer 2 software "bridge" network devices.  A
      5 ##  common use case is to merge together a hardware Ethernet device
      6 ##  with one or more WLANs so that several local devices appear to be
      7 ##  on the same network.
      8 
      9 {
     10   lib,
     11   pkgs,
     12   config,
     13   ...
     14 }:
     15 let
     16   inherit (lib) mkOption types;
     17   inherit (pkgs) liminix;
     18 in
     19 {
     20   imports = [ ../ifwait ];
     21 
     22   options = {
     23     system.service.bridge = {
     24       primary = mkOption { type = liminix.lib.types.serviceDefn; };
     25       members = mkOption { type = liminix.lib.types.serviceDefn; };
     26     };
     27   };
     28   config.system.service.bridge = {
     29     primary = config.system.callService ./primary.nix {
     30       ifname = mkOption {
     31         type = types.str;
     32         description = "bridge interface name to create";
     33       };
     34     };
     35     members = config.system.callService ./members.nix {
     36       primary = mkOption {
     37         type = liminix.lib.types.interface;
     38         description = "primary bridge interface";
     39       };
     40 
     41       members = mkOption {
     42         type = types.listOf liminix.lib.types.interface;
     43         description = "interfaces to add to the bridge";
     44       };
     45     };
     46   };
     47   config.kernel.config = {
     48     BRIDGE = "y";
     49     BRIDGE_IGMP_SNOOPING = "y";
     50   }
     51   // lib.optionalAttrs (config.system.service ? vlan) {
     52     # depends on bridge _and_ vlan. I would like there to be
     53     # a better way to test for the existence of vlan config:
     54     # maybe the module should set an `enabled` attribute?
     55     BRIDGE_VLAN_FILTERING = "y";
     56   };
     57 }