tpwrules / nixos-apple-silicon

Resources to install NixOS bare metal on Apple Silicon Macs
MIT License
872 stars 88 forks source link

docs/uefi-standalone: update idevicerestore/usbmuxd instructions #201

Closed flokli closed 5 months ago

flokli commented 5 months ago

Both nixpkgs master and stable provide sufficiently up-to-date versions.

Rework the section as suggested in https://github.com/tpwrules/nixos-apple-silicon/pull/188#issuecomment-2067804783.

Closes #188.

tpwrules commented 5 months ago

I'm not sure this is accurate, as I recall the purpose of the udev rules is to automatically start (and stop) usbmuxd. Also to set permissions so that sudo isn't required.

I think starting of usbmuxd should be removed, and so should the sudo invocation, if we indeed do want to change it to make sure that udev rules are required.

idevicerestore is also needed independent of OS, that sentence needs to be reworded.

flokli commented 5 months ago

I'm not sure this is accurate, as I recall the purpose of the udev rules is to automatically start (and stop) usbmuxd. Also to set permissions so that sudo isn't required.

I just peeked into the udev rules:

# usbmuxd (Apple Mobile Device Muxer listening on /var/run/usbmuxd)

# systemd should receive all events relating to device
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{PRODUCT}=="5ac/12[9a][0-9a-f]/*|5ac/190[1-5]/*|5ac/8600/*", TAG+="systemd"

# Initialize iOS devices into "deactivated" USB configuration state and activate usbmuxd
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{PRODUCT}=="5ac/12[9a][0-9a-f]/*|5ac/190[1-5]/*|5ac/8600/*", ACTION=="add", ENV{USBMUX_SUPPORTED}="1", ATTR{bConfigurationValue}="0", OWNER="usbmux", ENV{SYSTEMD_WANTS}="usbmuxd.service"

# Make sure properties don't get lost when bind action is called
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{PRODUCT}=="5ac/12[9a][0-9a-f]/*|5ac/190[1-5]/*|5ac/8600/*", ACTION=="bind", ENV{USBMUX_SUPPORTED}="1", OWNER="usbmux"

# Exit usbmuxd when the last device is removed
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{PRODUCT}=="5ac/12[9a][0-9a-f]/*|5ac/190[1-5]/*|5ac/8600/*", ACTION=="remove", RUN+="/nix/store/q0rbc365ycfjkggh74fwnvk7d0vfnb6i-usbmuxd-1.1.1+date=2023-05-05/sbin/usbmuxd -x"

The udev rule indeed starts the daemon. It however also is pretty much hardcoded to this being a system-wide systemd service. Meaning just installing the udev rule won't help on non-NixOS systems - you're better off just starting usbmuxd on your own, as root.

I'll update the docs accordingly, suggesting the NixOS option on NixOS, and manually starting as root on other systems. And also see how to update the part about idevicerestore.

tpwrules commented 5 months ago

Thank you, this is a good improvement.