Merge pull request 'sunshine: add apps, improve uaccess rules' (#946) from a-kenji-imp/sunshine into main
All checks were successful
checks / check-links (push) Successful in 21s
checks / checks (push) Successful in 37s
checks / checks-impure (push) Successful in 1m45s

This commit is contained in:
clan-bot 2024-03-12 21:23:06 +00:00
commit 2dd7304b57

View File

@ -1,13 +1,41 @@
{ pkgs, config, options, ... }:
{ pkgs, options, ... }:
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" ''
address_family = both
channels = 5
pkey = /var/lib/sunshine/sunshine.key
cert = /var/lib/sunshine/sunshine.cert
file_state = /var/lib/sunshine/state.json
file_apps = /var/lib/sunshine/apps.json
file_apps = ${apps}
credentials_file = /var/lib/sunshine/credentials.json
'';
in
@ -16,8 +44,7 @@ in
enable = pkgs.lib.mkEnableOption "Sunshine self-hosted game stream host for Moonlight";
};
config = pkgs.lib.mkMerge [
(pkgs.lib.mkIf cfg.enable
imports = [
{
networking.firewall = {
allowedTCPPorts = [
@ -68,12 +95,11 @@ in
# Required to simulate input
hardware.uinput.enable = true;
boot.kernelModules = [ "uinput" ];
# services.udev.extraRules = ''
# KERNEL=="uinput", SUBSYSTEM=="misc", OPTIONS+="static_node=uinput", TAG+="uaccess"
# '';
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.enable = true;
@ -109,19 +135,18 @@ in
wantedBy = [ "graphical-session.target" ];
};
}
)
]
# xdg.configFile."sunshine/apps.json".text = builtins.toJSON {
# env = "/run/current-system/sw/bin";
# apps = [
# {
# name = "Steam";
# output = "steam.txt";
# detached = [
# "${pkgs.util-linux}/bin/setsid ${pkgs.steam}/bin/steam steam://open/bigpicture"
# ];
# image-path = "steam.png";
# }
# ];
# };
# }
];
# xdg.configFile."sunshine/apps.json".text = builtins.toJSON {
# env = "/run/current-system/sw/bin";
# apps = [
# {
# name = "Steam";
# output = "steam.txt";
# detached = [
# "${pkgs.util-linux}/bin/setsid ${pkgs.steam}/bin/steam steam://open/bigpicture"
# ];
# image-path = "steam.png";
# }
# ];
# };
}