{ config, lib, pkgs, ... }: with lib; let hostname = config.instance.hostname; enable-gui = config.fudo.hosts."${hostname}".enable-gui; # 70:9C:D1:0E:48:AD in { config = mkIf enable-gui { environment.systemPackages = with pkgs; [ xboxdrv ]; services.udev.extraRules = let # btStartScript = concatStringsSep "," [ # ''SUBSYSTEM=="input"'' # ''ATTR{PHYS}=="70:9c:d1:0e:48:ad"'' # ''ATTR{ACTION}=="add"'' # ''ATTR{PRODUCT}=="5/57e/2009/8001"'' # '' # RUN+="${pkgs.systemd}/bin/systemctl start controller-8bitdo-ultimate-xinput@70_9C_D1_0E_48_AD"'' # ]; # btStopScript = concatStringsSep "," [ # ''SUBSYSTEM=="input"'' # ''ATTR{PHYS}=="70:9c:d1:0e:48:ad"'' # ''ATTR{ACTION}=="remove"'' # ''ATTR{PRODUCT}=="5/57e/2009/8001"'' # '' # RUN+="${pkgs.systemd}/bin/systemctl stop controller-8bitdo-ultimate-xinput@70_9C_D1_0E_48_AD"'' # ]; # usbStartScript = concatStringsSep "," [ # ''SUBSYSTEM=="usb"'' # ''ATTR{idVendor}=="2dc8"'' # ''ATTR{idProduct}=="3106"'' # ''ATTR{manufacturer}=="8BitDo"'' # '' # RUN+="${pkgs.systemd}/bin/systemctl start controller-8bitdo-ultimate-xinput@2dc8:3106"'' # ]; # usbStopScript = concatStringsSep "," [ # ''SUBSYSTEM=="usb"'' # ''ATTR{idVendor}=="2dc8"'' # ''ATTR{idProduct}=="3016"'' # NOTE: 3106 - connect, 3016 - disconnect # ''ATTR{manufacturer}=="8BitDo"'' # '' # RUN+="${pkgs.systemd}/bin/systemctl stop controller-8bitdo-ultimate-xinput@2dc8:3106'' # ]; startScript = concatStringsSep "," [ ''SUBSYSTEM=="input"'' ''ACTION=="add"'' ''ATTR{PRODUCT}=="5/57e/2009/8001"'' '' RUN+="${pkgs.systemd}/bin/systemctl start controller-8bitdo-ultimate-xinput@$env{ID_MODEL}"'' ]; stopScript = concatStringsSep "," [ ''SUBSYSTEM=="input"'' ''ACTION=="remove"'' ''ATTR{PRODUCT}=="5/57e/2009/8001"'' '' RUN+="${pkgs.systemd}/bin/systemctl stop controller-8bitdo-ultimate-xinput@$env{ID_MODEL}"'' ]; in concatStringsSep "\n" [ startScript stopScript ]; systemd.services."controller-8bitDo-ultimate-xinput@" = { unitConfig.Dsecription = "8BitDo Ultimate Controller XInput mode xboxdrv daemon"; serviceConfig = { Type = "simple"; ExecStart = pkgs.writeShellScript "controller-8bitDo-ultimate-xinput.sh" '' echo "starting xboxdrv for $ID_MODEL" ${pkgs.xboxdrv}/bin/xboxdrv --mimic-xpad --silent --type xbox360 --device-by-id %I --force-feedback; ''; }; }; }; }