feat: enable remote desktop - sunshine

This commit is contained in:
Ryan Yin
2025-03-01 08:47:35 +08:00
parent cfdf12b356
commit 9d26022139
2 changed files with 13 additions and 58 deletions

View File

@@ -3,11 +3,11 @@
mylib,
...
}: {
# imports = mylib.scanPaths ./.;
#
# environment.systemPackages = with pkgs; [
# waypipe
# moonlight-qt # moonlight client, for streaming games/desktop from a PC
# rustdesk # p2p remote desktop
# ];
imports = mylib.scanPaths ./.;
environment.systemPackages = with pkgs; [
waypipe
moonlight-qt # moonlight client, for streaming games/desktop from a PC
rustdesk # p2p remote desktop
];
}

View File

@@ -1,16 +1,8 @@
{
config,
lib,
pkgs,
...
}:
# ===============================================================================
#
# Sunshine: A self-hosted game stream server for Moonlight(Client).
# It's designed for game streaming, but it can be used for remote desktop as well.
#
# TODO: currently broken, fixed but not released yet: https://github.com/LizardByte/Sunshine/pull/1977
#
# How to use(Web Console: <https://localhost:47990/>):
# https://docs.lizardbyte.dev/projects/sunshine/en/latest/about/usage.html
#
@@ -20,51 +12,14 @@
# journalctl --user -u sunshine --since "2 minutes ago"
#
# References:
# https://github.com/LongerHV/nixos-configuration/blob/c7a06a2125673c472946cda68b918f68c635c41f/modules/nixos/sunshine.nix
# https://github.com/RandomNinjaAtk/nixos/blob/fc7d6e8734e6de175e0a18a43460c48003108540/services.sunshine.nix
# https://github.com/NixOS/nixpkgs/blob/nixos-24.11/nixos/modules/services/networking/sunshine.nix
#
# ===============================================================================
{
security.wrappers.sunshine = {
owner = "root";
group = "root";
capabilities = "cap_sys_admin+p";
source = "${pkgs.sunshine}/bin/sunshine";
};
# Requires to simulate input
boot.kernelModules = ["uinput"];
services.udev.extraRules = ''
KERNEL=="uinput", SUBSYSTEM=="misc", OPTIONS+="static_node=uinput", TAG+="uaccess"
'';
# systemd.user.services.sunshine = {
# description = "A self-hosted game stream server for Moonlight(Client)";
# after = ["graphical-session-pre.target"];
# wants = ["graphical-session-pre.target"];
# wantedBy = ["graphical-session.target"];
# startLimitIntervalSec = 500;
# startLimitBurst = 5;
#
# serviceConfig = {
# ExecStart = "${config.security.wrapperDir}/sunshine";
# Restart = "on-failure";
# RestartSec = "5s";
# };
# };
networking.firewall = {
allowedTCPPortRanges = [
{
from = 47984;
to = 48010;
}
];
allowedUDPPortRanges = [
{
from = 47998;
to = 48010;
}
];
services.sunshine = {
enable = true;
autoStart = true;
capSysAdmin = true; # only needed for Wayland -- omit this when using with Xorg
openFirewall = true;
};
}