summaryrefslogtreecommitdiff
path: root/config/networking/bridges.nix
blob: eecd34ee6d5d62771f63c53cb45a2f1c7f5b955a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
  config,
  lib,
  pkgs,
  ...
}: let
  bridges = config.personal.networking.interfaces.bridges;
in {
  config = {
    networking.bridges = lib.mapAttrs (_: _: {interfaces = [];}) bridges;
    systemd.services = lib.mkMerge ([
        {
          hostapd.postStart = lib.mkBefore ''
            sleep 10
          '';
        }
      ]
      ++ (lib.mapAttrsToList (bridge: {interfaces, ...}: {
          "${bridge}-netdev".script = ''
            echo Setting forward delay to 0 for ${bridge}...
            ip link set ${bridge} type bridge forward_delay 0
          '';

          hostapd.postStart =
            lib.concatMapStringsSep "\n" (interface: ''
              echo Setting ${interface} to hairpin mode...
              ${pkgs.iproute2}/bin/bridge link set dev ${interface} hairpin on
            '')
            interfaces;
        })
        bridges));
  };
}