summaryrefslogtreecommitdiffstats
path: root/tv/2configs/autotether.nix
blob: 43b5575c8186d8a7b0ace3bea83db76cdf7f488d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{ config, pkgs, ... }: let
  cfg.serial = "17e064850405";
in {
  systemd.services.usb_tether.serviceConfig = {
    SyslogIdentifier = "usb_tether";
    ExecStartPre = "${pkgs.android-tools}/bin/adb -s ${cfg.serial} wait-for-device";
    ExecStart = "${pkgs.android-tools}/bin/adb -s ${cfg.serial} shell svc usb setFunctions rndis";
  };
  services.udev.extraRules = /* sh */ ''
    ACTION=="add", SUBSYSTEM=="net", KERNEL=="usb*", NAME="android"

    ACTION=="add", SUBSYSTEM=="usb", ATTR{serial}=="${cfg.serial}", \
    TAG+="systemd", ENV{SYSTEMD_WANTS}="usb_tether.service"
  '';
  systemd.network.networks.android = {
    matchConfig.Name = "android";
    DHCP = "yes";
  };
}