sunshine: move pkgs use in resolution script and remove them from path of systemd service

This commit is contained in:
Giulio De Pasquale 2024-03-14 15:41:14 +00:00
parent 3b0e625c1a
commit c1c2a75ac4

View File

@ -14,24 +14,24 @@ let
resolutionScript = pkgs.writeTextFile {
name = "sunshine-resolution-script";
text = ''
#!/usr/bin/env bash
#!${pkgs.bash}/bin/bash
width=''${1:-1920}
height=''${2:-1080}
refresh_rate=''${3:-120}
# Get the modeline info from the 2nd row in the cvt output
modeline=$(cvt ''${width} ''${height} ''${refresh_rate} | gawk 'FNR == 2')
modeline=$(${pkgs.xorg.libxcvt}/bin/cvt ''${width} ''${height} ''${refresh_rate} | ${pkgs.gawk}/bin/gawk 'FNR == 2')
xrandr_mode_str=''${modeline//Modeline \"*\" /}
mode_alias="''${width}x''${height}"
echo "xrandr setting new mode ''${mode_alias} ''${xrandr_mode_str}"
xrandr --rmmode ''${mode_alias}
xrandr --newmode ''${mode_alias} ''${xrandr_mode_str}
xrandr --addmode DP-0 ''${mode_alias}
${pkgs.xorg.xrandr}/bin/xrandr --rmmode ''${mode_alias}
${pkgs.xorg.xrandr}/bin/xrandr --newmode ''${mode_alias} ''${xrandr_mode_str}
${pkgs.xorg.xrandr}/bin/xrandr --addmode DP-0 ''${mode_alias}
# Apply new xrandr mode
xrandr --output DP-0 --primary --mode ''${mode_alias} --pos 0x0 --rotate normal
${pkgs.xorg.xrandr}/bin/xrandr --output DP-0 --primary --mode ''${mode_alias} --pos 0x0 --rotate normal
/run/current-system/sw/bin/nvidia-settings -a 'SyncToVBlank=0'
/run/current-system/sw/bin/nvidia-smi --persistence-mode=ENABLED
@ -165,7 +165,7 @@ in
partOf = [ "graphical-session.target" ];
wants = [ "graphical-session.target" ];
after = [ "graphical-session.target" ];
path = with pkgs; [ resolutionScript xorg.xrandr bash xorg.libxcvt xorg.xorgserver gawk gamemode ];
path = with pkgs; [ resolutionScript gamemode ];
serviceConfig = {
ExecStart = "${sunshinePkg}/bin/sunshine ${configFile}";
Restart = "on-failure";