sunshine: add apps, improve uaccess rules

This commit is contained in:
a-kenji
2024-03-12 22:14:47 +01:00
parent 8a3250b1c9
commit 71cd46b0e9

View File

@@ -1,13 +1,41 @@
{ pkgs, config, options, ... }: { pkgs, options, ... }:
let let
cfg = options.services.sunshine; apps = pkgs.writeText "apps.json" (builtins.toJSON
{
env = {
PATH = "$(PATH):$(HOME)/.local/bin";
};
apps = [
{
name = "Desktop";
image-path = "desktop.png";
}
{
name = "Low Res Desktop";
image-path = "desktop.png";
prep-cmd = [
{
do = "xrandr --output HDMI-1 --mode 1920x1080";
undo = "xrandr --output HDMI-1 --mode 1920x1200";
}
];
}
{
name = "Steam Big Picture";
detached = [
"setsid steam steam://open/bigpicture"
];
image-path = "steam.png";
}
];
});
sunshineConfiguration = pkgs.writeText "sunshine.conf" '' sunshineConfiguration = pkgs.writeText "sunshine.conf" ''
address_family = both address_family = both
channels = 5 channels = 5
pkey = /var/lib/sunshine/sunshine.key pkey = /var/lib/sunshine/sunshine.key
cert = /var/lib/sunshine/sunshine.cert cert = /var/lib/sunshine/sunshine.cert
file_state = /var/lib/sunshine/state.json file_state = /var/lib/sunshine/state.json
file_apps = /var/lib/sunshine/apps.json file_apps = ${apps}
credentials_file = /var/lib/sunshine/credentials.json credentials_file = /var/lib/sunshine/credentials.json
''; '';
in in
@@ -16,8 +44,7 @@ in
enable = pkgs.lib.mkEnableOption "Sunshine self-hosted game stream host for Moonlight"; enable = pkgs.lib.mkEnableOption "Sunshine self-hosted game stream host for Moonlight";
}; };
config = pkgs.lib.mkMerge [ imports = [
(pkgs.lib.mkIf cfg.enable
{ {
networking.firewall = { networking.firewall = {
allowedTCPPorts = [ allowedTCPPorts = [
@@ -68,12 +95,11 @@ in
# Required to simulate input # Required to simulate input
hardware.uinput.enable = true; hardware.uinput.enable = true;
boot.kernelModules = [ "uinput" ]; boot.kernelModules = [ "uinput" ];
# services.udev.extraRules = ''
# KERNEL=="uinput", SUBSYSTEM=="misc", OPTIONS+="static_node=uinput", TAG+="uaccess"
# '';
services.udev.extraRules = '' services.udev.extraRules = ''
KERNEL=="uinput", GROUP="input", MODE="0660" OPTIONS+="static_node=uinput" KERNEL=="uinput", SUBSYSTEM=="misc", OPTIONS+="static_node=uinput", TAG+="uaccess"
''; '';
hardware.opengl.driSupport32Bit = true; hardware.opengl.driSupport32Bit = true;
hardware.opengl.enable = true; hardware.opengl.enable = true;
@@ -109,8 +135,7 @@ in
wantedBy = [ "graphical-session.target" ]; wantedBy = [ "graphical-session.target" ];
}; };
} }
) ];
]
# xdg.configFile."sunshine/apps.json".text = builtins.toJSON { # xdg.configFile."sunshine/apps.json".text = builtins.toJSON {
# env = "/run/current-system/sw/bin"; # env = "/run/current-system/sw/bin";
# apps = [ # apps = [
@@ -124,4 +149,4 @@ in
# } # }
# ]; # ];
# }; # };
# } }