]> Git — Sourcephile - julm/julm-nix.git/blob - nixos/profiles/networking.nix
graphical: install paprefs
[julm/julm-nix.git] / nixos / profiles / networking.nix
1 { config, pkgs, lib, hostName, ... }:
2 let
3 wg-intra-peers = import wireguard/wg-intra/peers.nix;
4 in
5 {
6 imports = [
7 networking/nftables.nix
8 ];
9 networking = {
10 hostName = hostName;
11 domain = lib.mkDefault "localdomain";
12 #search = [ "sourcephile.fr" ];
13 firewall = {
14 enable = lib.mkDefault true;
15 allowPing = lib.mkDefault true;
16 };
17 networkmanager = {
18 enable = lib.mkDefault config.services.xserver.enable;
19 #dhcp = "dhcpcd";
20 logLevel = lib.mkDefault "INFO";
21 wifi = {
22 #backend = "iwd";
23 #backend = "wpa_supplicant";
24 powersave = lib.mkDefault false;
25 };
26 };
27 usePredictableInterfaceNames = true;
28 };
29
30 programs.mtr.enable = true;
31 programs.usbtop.enable = true;
32
33 services.avahi = {
34 enable = lib.mkDefault true;
35 nssmdns = lib.mkDefault true;
36 openFirewall = lib.mkDefault false;
37 publish.enable = lib.mkDefault false;
38 };
39 networking.nftables.ruleset = lib.mkIf config.services.avahi.enable (''
40 table inet filter {
41 chain output-lan {
42 skuid root udp sport mdns udp dport mdns comment "avahi: multicast DNS"
43 }
44 }
45 '' + lib.optionalString config.services.avahi.openFirewall ''
46 table inet filter {
47 chain input-lan {
48 udp dport mdns comment "avahi: multicast DNS"
49 }
50 }
51 '');
52
53 services.openssh = {
54 enable = lib.mkDefault true;
55 forwardX11 = lib.mkDefault true;
56 openFirewall = lib.mkDefault false;
57 listenAddresses = [
58 { addr = wg-intra-peers.${hostName}.ipv4; port = 22; }
59 ];
60 };
61
62 environment.etc."NetworkManager/dispatcher.d/congctl" = {
63 mode = "700";
64 source = pkgs.writeShellScript "congctl" ''
65 case $NM_DISPATCHER_ACTION in
66 up)
67 case $DEVICE_IP_IFACE in
68 # WLAN or WWAN
69 # https://en.wikipedia.org/wiki/TCP_congestion_control#TCP_Westwood+
70 wl*|ww*)
71 ip route show dev $DEVICE_IP_IFACE |
72 while read -r route; do
73 ip route change $route dev $DEVICE_IP_IFACE congctl westwood
74 done
75 ip r >>/tmp/log
76 ;;
77 esac
78 ;;
79 esac
80 '';
81 };
82 }