1 { config, lib, pkgs, ... }:
7 defaultUserGroup = "usbmux";
10 cfg = config.services.usbmuxd;
15 options.services.usbmuxd = {
19 description = lib.mdDoc ''
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;
30 description = lib.mdDoc ''
31 The user usbmuxd should use to run after startup.
37 default = defaultUserGroup;
38 description = lib.mdDoc ''
39 The group usbmuxd should use to run after startup.
44 config = mkIf cfg.enable {
46 users.users = optionalAttrs (cfg.user == defaultUserGroup) {
48 description = "usbmuxd user";
54 users.groups = optionalAttrs (cfg.group == defaultUserGroup) {
58 # Give usbmuxd permission for Apple devices
59 services.udev.extraRules = ''
60 SUBSYSTEM=="usb", ATTR{idVendor}=="${apple}", GROUP="${cfg.group}"
63 systemd.services.usbmuxd = {
64 description = "usbmuxd";
65 wantedBy = [ "multi-user.target" ];
66 unitConfig.Documentation = "man:usbmuxd(8)";
68 # Trigger the udev rule manually. This doesn't require replugging the
69 # device when first enabling the option to get it to work
70 ExecStartPre = "${pkgs.udev}/bin/udevadm trigger -s usb -a idVendor=${apple}";
71 ExecStart = "${pkgs.usbmuxd}/bin/usbmuxd -U ${cfg.user} -f";