1 { config, pkgs, lib, hostName, ... }:
5 networking/nftables.nix
9 # Improve MTU detection
10 # This can thaw TCP connections stalled by a host
11 # requiring a lower MTU along the path,
12 # though it would do so after a little delay
13 # so it's better to set a low MTU when possible.
14 "net/ipv4/tcp_mtu_probing" = 1;
19 domain = mkDefault "wg";
20 #search = [ "sourcephile.fr" ];
22 enable = mkDefault true;
23 allowPing = mkDefault true;
26 enable = mkDefault config.services.xserver.enable;
28 logLevel = mkDefault "INFO";
31 #backend = "wpa_supplicant";
32 powersave = mkDefault false;
35 usePredictableInterfaceNames = true;
38 programs.mtr.enable = true;
39 programs.traceroute.enable = mkDefault true;
40 programs.usbtop.enable = true;
43 nssmdns = mkDefault true;
44 openFirewall = mkDefault false;
45 publish.enable = mkDefault false;
47 networking.nftables.ruleset = mkIf config.services.avahi.enable (''
50 skuid root udp sport mdns udp dport mdns comment "avahi: multicast DNS"
53 '' + optionalString config.services.avahi.openFirewall ''
56 udp dport mdns comment "avahi: multicast DNS"
62 enable = mkDefault true;
63 settings.X11Forwarding = mkDefault true;
64 openFirewall = mkDefault false;
67 # Fix https://github.com/NixOS/nixpkgs/issues/180175 by removing -s (aka. --wait-for-startup)
68 systemd.services.NetworkManager-wait-online = {
69 unitConfig.StartLimitIntervalSec = 0;
71 ExecStart = [ "" "${pkgs.networkmanager}/bin/nm-online -q" ];
72 Restart = "on-failure";
76 environment.etc."NetworkManager/dispatcher.d/congctl" = {
78 source = pkgs.writeShellScript "congctl" ''
79 case $NM_DISPATCHER_ACTION in
81 case $DEVICE_IP_IFACE in
83 # https://en.wikipedia.org/wiki/TCP_congestion_control#TCP_Westwood+
85 ip route show dev $DEVICE_IP_IFACE |
86 while read -r route; do
87 ip route change $route dev $DEVICE_IP_IFACE congctl westwood