135 lines
4.1 KiB
Nix
135 lines
4.1 KiB
Nix
{ pkgs, ... }:
|
|
|
|
let
|
|
user = "sunshine";
|
|
configFile = pkgs.writeText "sunshine.conf"
|
|
''
|
|
output_name=1
|
|
origin_web_ui_allowed=lan
|
|
channels=2
|
|
min_threads=12
|
|
global_prep_cmd=[{"do":"/run/current-system/sw/bin/sh -c \"/run/current-system/sw/bin/xrandr --output DP-0 --mode \"''${SUNSHINE_CLIENT_WIDTH}x''${SUNSHINE_CLIENT_HEIGHT}\" --rate ''${SUNSHINE_CLIENT_FPS}\""}]
|
|
'';
|
|
sunshineOverride = pkgs.sunshine.override { cudaSupport = true; stdenv = pkgs.cudaPackages.backendStdenv; };
|
|
in
|
|
{
|
|
security = {
|
|
polkit.extraConfig = ''
|
|
polkit.addRule(function(action, subject) {
|
|
if (action.id == "org.freedesktop.login1.suspend" ||
|
|
action.id == "org.freedesktop.login1.suspend-multiple-sessions" ||
|
|
action.id == "org.freedesktop.login1.hibernate" ||
|
|
action.id == "org.freedesktop.login1.hibernate-multiple-sessions")
|
|
{
|
|
return polkit.Result.NO;
|
|
}
|
|
});
|
|
'';
|
|
};
|
|
|
|
systemd.targets = {
|
|
sleep.enable = false;
|
|
suspend.enable = false;
|
|
hibernate.enable = false;
|
|
hybrid-sleep.enable = false;
|
|
};
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
sunshineOverride
|
|
xorg.xrandr
|
|
xorg.xorgserver
|
|
];
|
|
sound.enable = true;
|
|
hardware.pulseaudio.enable = true;
|
|
|
|
services.xserver = {
|
|
enable = true;
|
|
videoDrivers = [ "nvidia" ];
|
|
|
|
displayManager = {
|
|
sddm = {
|
|
enable = true;
|
|
wayland.enable = false;
|
|
autoLogin.relogin = true;
|
|
};
|
|
autoLogin = {
|
|
inherit user;
|
|
enable = true;
|
|
};
|
|
};
|
|
desktopManager.xfce.enable = true;
|
|
|
|
monitorSection = ''
|
|
HorizSync 5.0 - 1000.0
|
|
VertRefresh 5.0 - 1000.0
|
|
Option "DPMS"
|
|
'';
|
|
|
|
deviceSection = ''
|
|
VendorName "NVIDIA Corporation"
|
|
Option "CustomEDID" "DFP-1:/etc/X11/120edid.bin"
|
|
Option "ConnectedMonitor" "DFP-1"
|
|
'';
|
|
|
|
screenSection = ''
|
|
Monitor "Configured Monitor"
|
|
DefaultDepth 24
|
|
|
|
Option "ModeValidation" "NoVertRefreshCheck, NoHorizSyncCheck, NoMaxSizeCheck, NoMaxPClkCheck, AllowNonEdidModes, NoEdidMaxPClkCheck"
|
|
|
|
SubSection "Display"
|
|
Depth 24
|
|
EndSubSection
|
|
'';
|
|
};
|
|
|
|
# Sunshine user, service and config
|
|
users.users.${user} = {
|
|
isNormalUser = true;
|
|
home = "/home/${user}";
|
|
description = "Sunshine Server";
|
|
extraGroups = [ "wheel" "networkmanager" "input" "video" "sound" ];
|
|
openssh.authorizedKeys.keys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC1we38/N+t8Ah5yrLof8QUwhrob7/VXFKIddaJeOVBLuDVnW7ljiAtdtEiL69D/DV4Ohmt5wMvkAAjfuHmim6FD9A6lzPbSU4KH9W2dcckszKbbI636kuDwem/xui6BW3wJa6P+0xW5ksygEAkzcK2PXuC2b4B9uwhuUdKahiGMKDxISG/WianqAe72cGMfNkYvion3Y1VsMLUdm48d2ABnxNpr7NI9B5iJ8dziOft9gpgfz13CCQRlReo75gk/4xI+vSNrQp7eR+wzJy2/dZg/T8jtyA9Q6jVxrxBpqQ1LNXkAKaJkGo9OabF6Wgpzp+YTAurL4nwR2NaJxwFuyoKvACQy0ai4jrS3206gC6JXZv8ktZMZrwUN+jPqCwfgh5qObFkAqKCxbp52ioDek2MQLdOvzQBX//DBhGEp5rzHGLZ3vhRIiiQiaof5sF5zWiYDW5mqezSPNxJPX/BrTP/Wbs/jpwTLBh3wytiia0S1WXQmya89bqzTPFiDWvTRA62EVKB/JaQtPQQOFAxWwg799DMycPeZ81xttZOyMtI/MZSddyqx2S8fWGwvToZQvuZ38mSIpFseLM1IkgabRIrAmat5SBNGGy9Dqa0eMEa7bwIY/4CMB1y6HMTnaoMXA6cnQfHMoB/zyTZ6oTXIeqeOyiZsK+RN0Mvahj8mXi7dw== giulio@giulio-X230" ];
|
|
};
|
|
|
|
|
|
systemd.user.services.${user} = {
|
|
description = "Sunshine server";
|
|
wantedBy = [ "graphical-session.target" ];
|
|
startLimitIntervalSec = 500;
|
|
startLimitBurst = 5;
|
|
partOf = [ "graphical-session.target" ];
|
|
wants = [ "graphical-session.target" ];
|
|
after = [ "graphical-session.target" ];
|
|
|
|
serviceConfig = {
|
|
ExecStart = "${sunshineOverride}/bin/sunshine ${configFile}";
|
|
Restart = "on-failure";
|
|
RestartSec = "5s";
|
|
};
|
|
};
|
|
|
|
services.avahi.publish.userServices = true;
|
|
boot.kernelModules = [ "uinput" ];
|
|
|
|
programs.steam.enable = true;
|
|
|
|
hardware = {
|
|
opengl = {
|
|
enable = true;
|
|
driSupport = true;
|
|
driSupport32Bit = true;
|
|
};
|
|
|
|
nvidia = {
|
|
modesetting.enable = true;
|
|
powerManagement.enable = false;
|
|
powerManagement.finegrained = false;
|
|
open = false;
|
|
nvidiaSettings = true;
|
|
};
|
|
};
|
|
|
|
users.groups.media.members = [ user ];
|
|
}
|