···
7
+
defaultUserGroup = "usbmux";
10
+
cfg = config.services.usbmuxd;
6
-
options.services.usbmuxd.enable = mkOption {
10
-
Enable the usbmuxd ("USB multiplexing daemon") service. This daemon is in
11
-
charge of multiplexing connections over USB to an iOS device. This is
12
-
needed for transferring data from and to iOS devices (see ifuse). Also
13
-
this may enable plug-n-play tethering for iPhones.
15
+
options.services.usbmuxd = {
20
+
Enable the usbmuxd ("USB multiplexing daemon") service. This daemon is
21
+
in charge of multiplexing connections over USB to an iOS device. This is
22
+
needed for transferring data from and to iOS devices (see ifuse). Also
23
+
this may enable plug-n-play tethering for iPhones.
29
+
default = defaultUserGroup;
31
+
The user usbmuxd should use to run after startup.
37
+
default = defaultUserGroup;
39
+
The group usbmuxd should use to run after startup.
44
+
config = mkIf cfg.enable {
46
+
users.extraUsers = optional (cfg.user == defaultUserGroup) {
48
+
description = "usbmuxd user";
52
+
users.extraGroups = optional (cfg.group == defaultUserGroup) {
56
+
# Give usbmuxd permission for Apple devices
57
+
services.udev.extraRules = ''
58
+
SUBSYSTEM=="usb", ATTR{idVendor}=="${apple}", GROUP="${cfg.group}"
17
-
config = mkIf config.services.usbmuxd.enable {
systemd.services.usbmuxd = {
wantedBy = [ "multi-user.target" ];
unitConfig.Documentation = "man:usbmuxd(8)";
22
-
serviceConfig.ExecStart = "${pkgs.usbmuxd}/bin/usbmuxd -f";
66
+
# Trigger the udev rule manually. This doesn't require replugging the
67
+
# device when first enabling the option to get it to work
68
+
ExecStartPre = "${pkgs.libudev}/bin/udevadm trigger -s usb -a idVendor=${apple}";
69
+
ExecStart = "${pkgs.usbmuxd}/bin/usbmuxd -U ${cfg.user} -f";