# ... # imports = [ /path/to/iphone.nix ]; # iphone.enable = true; # iphone.user = "yourusername"; # ... # Then rebuild system. Attach iPhone via cable, open terminal and run command `iphone` # It will fail, but there will occure a dialog on your iPhone to "trust this computer" # Press OK there and run `iphone` again. If it succeeds it will open a freshly mounted folder { config, pkgs, lib, ... }: let cfg = config.iphone; in { options.iphone = { enable = lib.mkOption { default = false; }; directory = lib.mkOption { default = "/run/media/iPhone"; }; user = lib.mkOption { }; }; config = lib.mkIf cfg.enable { environment.systemPackages = [ pkgs.libimobiledevice pkgs.usbmuxd (pkgs.writeScriptBin "iphone" '' sudo systemctl restart iphone \ && ${pkgs.gnome2.libgnome}/bin/gnome-open ${cfg.directory} '') ]; services.usbmuxd = { enable = true; user = cfg.user; #https://nixos.wiki/wiki/IOS #package = pkgs.usbmuxd2 }; systemd.services.iphone = { preStart = "mkdir -p ${cfg.directory}; chown ${cfg.user} ${cfg.directory}"; script = '' ${pkgs.libimobiledevice}/bin/idevicepair pair \ && exec ${pkgs.ifuse}/bin/ifuse ${cfg.directory} ''; serviceConfig = { PermissionsStartOnly = true; User = cfg.user; Type = "forking"; }; }; }; }