From 78d72274713d9e4e3aaca19d1edda7c0f58139b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vili=20Sinerv=C3=A4?= Date: Sat, 11 Jan 2025 14:27:15 +0200 Subject: [PATCH] Add basic conf for sunshine game streaming on NixOS --- gaming.nix | 17 +++++++++++++ hardware-specific/nvidia.nix | 16 ++++++++++++ machine-confs/gaming.nix | 25 +++++++++++++++++++ machine-confs/helium.nix | 2 +- machine-confs/lithium.nix | 1 + .../{game-streaming.nix => moonlight.nix} | 0 services/sunshine.nix | 15 +++++++++++ 7 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 gaming.nix create mode 100644 hardware-specific/nvidia.nix create mode 100644 machine-confs/gaming.nix rename services/{game-streaming.nix => moonlight.nix} (100%) create mode 100644 services/sunshine.nix diff --git a/gaming.nix b/gaming.nix new file mode 100644 index 0000000..c9ecc8b --- /dev/null +++ b/gaming.nix @@ -0,0 +1,17 @@ +{ config, pkgs, ... }: +{ + assertions = [ + { + assertion = config.services.xserver.enable; + message = "Gaming does not work without a desktop!"; + } + ]; + + programs = { + steam = { + enable = true; + extraCompatPackages = [ pkgs.proton-ge-bin ]; + }; + gamemode.enable = true; + }; +} diff --git a/hardware-specific/nvidia.nix b/hardware-specific/nvidia.nix new file mode 100644 index 0000000..64ee5c7 --- /dev/null +++ b/hardware-specific/nvidia.nix @@ -0,0 +1,16 @@ +{ config, pkgs, ... }: +{ + hardware = { + graphics.enable = true; + nvidia = { + open = true; + forceFullCompositionPipeline = true; + }; + }; + + services = { + xserver = pkgs.lib.mkIf config.services.xserver.enable { + videoDrivers = [ "nvidia" ]; + }; + }; +} diff --git a/machine-confs/gaming.nix b/machine-confs/gaming.nix new file mode 100644 index 0000000..8ecf291 --- /dev/null +++ b/machine-confs/gaming.nix @@ -0,0 +1,25 @@ +{ pkgs, ... }: +{ + networking.hostName = "gaming"; + + imports = [ + ../base.nix + ../users/vili.nix + ../desktop.nix + ../gaming.nix + ../services/sunshine.nix + # ../hardware-specific/nvidia.nix + ]; + + users.users.vili.hashedPasswordFile = pkgs.lib.mkForce null; + + swapDevices = pkgs.lib.mkForce [ + { + device = "/var/lib/swapfile"; + size = 16 * 1024; + } + ]; + + # HARDWARE SPECIFIC + services.qemuGuest.enable = true; +} diff --git a/machine-confs/helium.nix b/machine-confs/helium.nix index ce245fc..9dfcd7e 100644 --- a/machine-confs/helium.nix +++ b/machine-confs/helium.nix @@ -72,7 +72,7 @@ ../onlykey.nix ../services/syncthing.nix ../services/redshift.nix - ../services/game-streaming.nix + ../services/moonlight.nix ../hardware-specific/keychron-q11.nix ../hardware-specific/trackball.nix ../hardware-specific/amd-laptop.nix diff --git a/machine-confs/lithium.nix b/machine-confs/lithium.nix index 0465388..086d1aa 100644 --- a/machine-confs/lithium.nix +++ b/machine-confs/lithium.nix @@ -54,6 +54,7 @@ ../onlykey.nix ../services/syncthing.nix ../services/redshift.nix + ../services/moonlight.nix ../hardware-specific/keychron-q11.nix ../hardware-specific/trackball.nix ../hardware-specific/usb-automount.nix diff --git a/services/game-streaming.nix b/services/moonlight.nix similarity index 100% rename from services/game-streaming.nix rename to services/moonlight.nix diff --git a/services/sunshine.nix b/services/sunshine.nix new file mode 100644 index 0000000..1fd252f --- /dev/null +++ b/services/sunshine.nix @@ -0,0 +1,15 @@ +{ config, ... }: +{ + assertions = [ + { + assertion = config.services.xserver.enable; + message = "Game streaming does not work without a desktop!"; + } + ]; + + services.sunshine = { + enable = true; + autoStart = true; + openFirewall = true; + }; +}