2023-08-07 22:43:12 +02:00
|
|
|
## Bridge module
|
2023-08-07 23:14:58 +02:00
|
|
|
## =============
|
2023-08-07 22:43:12 +02:00
|
|
|
##
|
|
|
|
## Allows creation of Layer 2 software "bridge" network devices. A
|
|
|
|
## common use case is to merge together a hardware Ethernet device
|
|
|
|
## with one or more WLANs so that several local devices appear to be
|
2023-08-19 00:58:06 +02:00
|
|
|
## on the same network.
|
2023-08-07 22:43:12 +02:00
|
|
|
|
|
|
|
|
2023-07-20 12:46:19 +02:00
|
|
|
{ lib, pkgs, config, ...}:
|
|
|
|
let
|
|
|
|
inherit (lib) mkOption types;
|
|
|
|
inherit (pkgs.liminix.services) oneshot;
|
2023-08-05 15:08:02 +02:00
|
|
|
inherit (pkgs) liminix;
|
2023-07-20 12:46:19 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
2023-08-28 00:45:27 +02:00
|
|
|
system.service.bridge = {
|
|
|
|
primary = mkOption { type = liminix.lib.types.serviceDefn; };
|
|
|
|
members = mkOption { type = liminix.lib.types.serviceDefn; };
|
2023-07-20 12:46:19 +02:00
|
|
|
};
|
|
|
|
};
|
2023-08-28 00:45:27 +02:00
|
|
|
config.system.service.bridge = {
|
|
|
|
primary = liminix.callService ./primary.nix {
|
2023-08-16 20:44:00 +02:00
|
|
|
ifname = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "bridge interface name to create";
|
2023-08-05 15:08:02 +02:00
|
|
|
};
|
|
|
|
};
|
2023-08-28 00:45:27 +02:00
|
|
|
members = liminix.callService ./members.nix {
|
|
|
|
primary = mkOption {
|
|
|
|
type = liminix.lib.types.interface;
|
|
|
|
description = "primary bridge interface";
|
|
|
|
};
|
|
|
|
|
|
|
|
members = mkOption {
|
|
|
|
type = types.listOf liminix.lib.types.interface;
|
|
|
|
description = "interfaces to add to the bridge";
|
|
|
|
};
|
|
|
|
};
|
2023-07-20 12:46:19 +02:00
|
|
|
};
|
2023-08-30 18:29:42 +02:00
|
|
|
config.kernel.config = {
|
|
|
|
BRIDGE = "y";
|
|
|
|
BRIDGE_IGMP_SNOOPING = "y";
|
2023-08-31 19:24:09 +02:00
|
|
|
} // lib.optionalAttrs (config.system.service ? vlan) {
|
|
|
|
# depends on bridge _and_ vlan. I would like there to be
|
|
|
|
# a better way to test for the existence of vlan config:
|
|
|
|
# maybe the module should set an `enabled` attribute?
|
|
|
|
BRIDGE_VLAN_FILTERING = "y";
|
|
|
|
};
|
2023-07-20 12:46:19 +02:00
|
|
|
}
|