]> Git — Sourcephile - julm/julm-nix.git/blob - hosts/aubergine/networking/lte.nix
aubergine: lte: clarify settings
[julm/julm-nix.git] / hosts / aubergine / networking / lte.nix
1 { pkgs, lib, config, ... }:
2 with (import ./names-and-numbers.nix);
3 let
4 inherit (config.users) users;
5 in
6 {
7 networking.nftables.ruleset = ''
8 table inet filter {
9 chain input {
10 iifname ${lteIface} jump input-net
11 iifname ${lteIface} log level warn prefix "input-net: " counter drop
12 }
13 chain output-net {
14 ip daddr 10.151.0.1 tcp dport 8080 counter accept \
15 comment "mmsd: Prixtel/SFR"
16 }
17 chain output {
18 oifname ${lteIface} jump output-net
19 oifname ${lteIface} log level warn prefix "output-net: " counter drop
20 }
21 chain forward-to-net {
22 }
23 chain forward-from-net {
24 }
25 chain forward-to-net { }
26 chain forward-from-net { }
27 chain forward {
28 iifname { ${wifiIface}, ${eth1Iface}, ${eth2Iface}, ${eth3Iface} } oifname ${lteIface} goto forward-to-net
29 iifname ${lteIface} oifname { ${wifiIface}, ${eth1Iface}, ${eth2Iface}, ${eth3Iface} } goto forward-from-net
30 }
31 }
32 table inet nat {
33 chain postrouting {
34 iifname { ${wifiIface}, ${eth1Iface}, ${eth2Iface}, ${eth3Iface} } oifname ${lteIface} masquerade
35 }
36 }
37 '';
38 services.mmsd.enable = true;
39 services.mmsd.extraArgs = [ "--debug" ];
40 systemd.services.ModemManager.serviceConfig.ExecStart =
41 lib.mkForce [
42 ""
43 "${pkgs.modemmanager-1-18}/bin/ModemManager --debug"
44 #"${pkgs.modemmanager-1-20-4}/bin/ModemManager --debug"
45 ];
46 systemd.services.NetworkManager.wants = [ "ModemManager.service" ];
47 services.dbus.packages = [ pkgs.dconf ];
48 programs.dconf.enable = true;
49 environment.etc."NetworkManager/system-connections/Prixtel.nmconnection" = {
50 mode = "600";
51 text = ''
52 [connection]
53 id=Prixtel
54 uuid=b223f550-dff1-4ba3-9755-cd4557faaa5a
55 type=gsm
56 autoconnect=true
57 autoconnect-priority=999
58 autoconnect-retries=0
59 permissions=NULL
60
61 [gsm]
62 apn=sl2sfr
63 number=*99#
64 #home-only=true
65
66 [ppp]
67
68 [ipv4]
69 method=auto
70 dhcp-send-hostname=false
71
72 [ipv6]
73 method=auto
74 addr-gen-mode=stable-privacy
75 ip6-privacy=2
76 dhcp-send-hostname=false
77
78 [proxy]
79 '';
80 };
81 systemd.services.watch-lte = {
82 after = [ "NetworkManager-wait-online.service" ];
83 requires = [ "NetworkManager-wait-online.service" ];
84 wantedBy = [ "network-online.target" ];
85 #startAt = "*:0/5"; # every 5 min
86 path = with pkgs; [ inetutils networkmanager ];
87 unitConfig = { StartLimitIntervalSec = 0; };
88 serviceConfig = {
89 Type = "simple";
90 IPAddressAllow = [ "9.9.9.9" ];
91 RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ];
92 ExecStart = pkgs.writeShellScript "watch-lte" ''
93 set -ux
94 while sleep 300; do
95 ping -c 1 9.9.9.9 ||
96 nmcli connection up Prixtel
97 done
98 '';
99 Restart = "on-failure";
100 RestartSec = "30s";
101 };
102 };
103 environment.systemPackages = [
104 pkgs.modem-manager-gui
105 pkgs.libmbim
106 pkgs.chatty
107 pkgs.gnome.gnome-contacts
108 pkgs.picocom
109 pkgs.tio
110 pkgs.calls
111 pkgs.d-spy
112 # https://gitlab.com/mobian1/callaudiod/-/issues/26
113 # https://gitlab.com/mobian1/callaudiod/-/issues/27
114 pkgs.callaudiod
115 ];
116 }