nixos-conf/services/sunshine.nix

66 lines
1.4 KiB
Nix
Raw Normal View History

2025-01-11 17:47:07 +02:00
{ pkgs, config, ... }:
2025-01-11 17:52:53 +02:00
let
2025-01-11 18:41:00 +02:00
sunshineCuda = pkgs.sunshine.override {
cudaSupport = true;
stdenv = pkgs.cudaPackages.backendStdenv;
};
2025-01-11 18:04:00 +02:00
resolution_list = [
2025-01-11 17:56:58 +02:00
"1920x1080"
"2400x1080"
"2160x1440"
"2560x1440"
"3840x2160"
];
2025-01-11 17:52:53 +02:00
in
{
2024-06-06 22:16:29 +03:00
assertions = [
{
assertion = config.services.xserver.enable;
message = "Game streaming does not work without a desktop!";
}
];
services.sunshine = {
2025-01-11 18:41:00 +02:00
package = sunshineCuda;
enable = true;
autoStart = true;
openFirewall = true;
2025-01-11 17:47:07 +02:00
settings = {
2025-01-12 00:00:41 +02:00
min_log_level = "debug";
encoder = "nvenc";
2025-01-11 17:47:07 +02:00
sunshine_name = "Gaming NixOS";
2025-01-11 18:04:00 +02:00
resolutions = ''
[
1920x1080,
2400x1080,
2160x1440,
2560x1440,
3840x2160
]
'';
2025-01-11 18:00:29 +02:00
fps = ''
[30, 60, 90, 120]
'';
2025-01-11 17:47:07 +02:00
address_family = "both";
};
applications = {
2025-01-11 18:04:00 +02:00
apps =
(
resolutions:
map (resolution: {
name = "${resolution} Desktop";
2025-01-11 18:41:00 +02:00
prep-cmd = [
{
2025-01-11 18:44:46 +02:00
do = "${pkgs.xorg.xrandr}/bin/xrandr --output HDMI-0 --mode ${resolution}";
undo = "${pkgs.xorg.xrandr}/bin/xrandr --output HDMI-0 --auto";
2025-01-11 18:41:00 +02:00
}
];
2025-01-11 18:04:00 +02:00
exclude-global-prep-cmd = "false";
auto-detach = "true";
}) resolutions
)
resolution_list;
2025-01-11 17:47:07 +02:00
};
};
}