]> Git — Sourcephile - julm/julm-nix.git/blob - hosts/aubergine/networking/lte.nix
linux: use mkDefault to select kernel
[julm/julm-nix.git] / hosts / aubergine / networking / lte.nix
1 { pkgs, 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.NetworkManager.wants = [ "ModemManager.service" ];
41 services.dbus.packages = [ pkgs.dconf ];
42 programs.dconf.enable = true;
43 environment.etc."NetworkManager/system-connections/Prixtel.nmconnection" = {
44 mode = "600";
45 text = ''
46 [connection]
47 id=Prixtel
48 uuid=b223f550-dff1-4ba3-9755-cd4557faaa5a
49 type=gsm
50 autoconnect=true
51 autoconnect-retries=0
52
53 [gsm]
54 apn=sl2sfr
55 number=*99#
56 #home-only=true
57
58 [ppp]
59
60 [ipv4]
61 method=auto
62 dhcp-send-hostname=false
63
64 [ipv6]
65 method=auto
66 addr-gen-mode=stable-privacy
67 ip6-privacy=2
68 dhcp-send-hostname=false
69
70 [proxy]
71 '';
72 };
73 systemd.services.watch-lte = {
74 wantedBy = [ "multi-user.target" ];
75 startAt = "*:0/5"; # every 5 min
76 path = with pkgs; [ inetutils networkmanager ];
77 unitConfig = { StartLimitIntervalSec = 0; };
78 serviceConfig = {
79 Type = "simple";
80 IPAddressAllow = [ "9.9.9.9" ];
81 RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ];
82 ExecStart = pkgs.writeShellScript "watch-lte" ''
83 set -eux
84 ping -c 1 9.9.9.9 ||
85 nmcli connection up Prixtel
86 '';
87 Restart = "on-failure";
88 RestartSec = "30s";
89 };
90 };
91 environment.systemPackages = [
92 pkgs.modem-manager-gui
93 pkgs.libmbim
94 pkgs.chatty
95 pkgs.gnome.gnome-contacts
96 pkgs.picocom
97 pkgs.tio
98 pkgs.calls
99 pkgs.dfeet
100 # https://gitlab.com/mobian1/callaudiod/-/issues/26
101 # https://gitlab.com/mobian1/callaudiod/-/issues/27
102 pkgs.callaudiod
103 ];
104 }