1 { pkgs, lib, config, ... }:
2 with (import ./names-and-numbers.nix);
4 inherit (config.users) users;
5 modemmanager = pkgs.modemmanager-1-18;
6 #modemmanager = pkgs.modemmanager-1-20-4;
9 networking.nftables.ruleset = ''
12 iifname ${lteIface} jump input-net
13 iifname ${lteIface} log level warn prefix "input-net: " counter drop
16 ip daddr 10.151.0.1 tcp dport 8080 counter accept \
17 comment "mmsd: Prixtel/SFR"
20 oifname ${lteIface} jump output-net
21 oifname ${lteIface} log level warn prefix "output-net: " counter drop
23 chain forward-to-net {
25 chain forward-from-net {
27 chain forward-to-net { }
28 chain forward-from-net { }
30 iifname { ${wifiIface}, ${eth1Iface}, ${eth2Iface}, ${eth3Iface} } oifname ${lteIface} goto forward-to-net
31 iifname ${lteIface} oifname { ${wifiIface}, ${eth1Iface}, ${eth2Iface}, ${eth3Iface} } goto forward-from-net
36 iifname { ${wifiIface}, ${eth1Iface}, ${eth2Iface}, ${eth3Iface} } oifname ${lteIface} masquerade
40 services.mmsd.enable = true;
41 services.mmsd.extraArgs = [ "--debug" ];
42 systemd.services.ModemManager.serviceConfig.ExecStart =
45 # See https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/780
46 "${modemmanager}/bin/ModemManager --debug"
48 systemd.services.NetworkManager.wants = [ "ModemManager.service" ];
49 services.dbus.packages = [ pkgs.dconf ];
50 programs.dconf.enable = true;
51 environment.etc."NetworkManager/system-connections/Prixtel.nmconnection" = {
56 uuid=b223f550-dff1-4ba3-9755-cd4557faaa5a
59 autoconnect-priority=999
71 dhcp-send-hostname=false
75 addr-gen-mode=stable-privacy
77 dhcp-send-hostname=false
82 systemd.services.watch-lte = {
83 after = [ "ModemManager.service" "NetworkManager.service" "NetworkManager-wait-online.service" ];
84 requires = [ "ModemManager.service" "NetworkManager.service" "NetworkManager-wait-online.service" ];
85 wantedBy = [ "network-online.target" ];
86 #startAt = "*:0/5"; # every 5 min
87 path = with pkgs; [ inetutils modemmanager networkmanager jq ];
88 unitConfig = { StartLimitIntervalSec = 0; };
91 IPAddressAllow = [ "9.9.9.9" ];
92 RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ];
93 ExecStart = pkgs.writeShellScript "watch-lte" ''
97 if ping 9.9.9.9 --count 1 --linger 20 --interval 1 --quiet --numeric
98 then lastPONG=$(date +%s)
100 if test $(( $(date +%s) - lastPONG )) -gt 300
102 modem=$(mmcli -L -J | jq -r '.["modem-list"][0]') || true
103 mmcli -m "$modem" --command "AT+CFUN=1,1" || true
105 systemctl restart ModemManager
107 nmcli connection up Prixtel
112 Restart = "on-failure";
116 environment.systemPackages = [
117 pkgs.modem-manager-gui
120 pkgs.gnome.gnome-contacts
125 # https://gitlab.com/mobian1/callaudiod/-/issues/26
126 # https://gitlab.com/mobian1/callaudiod/-/issues/27