From 9d26022139576b5f5ee221206d796c40a9d095e5 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Sat, 1 Mar 2025 08:47:35 +0800 Subject: [PATCH] feat: enable remote desktop - sunshine --- .../nixos/desktop/remote-desktop/default.nix | 14 ++--- .../nixos/desktop/remote-desktop/sunshine.nix | 57 ++----------------- 2 files changed, 13 insertions(+), 58 deletions(-) diff --git a/modules/nixos/desktop/remote-desktop/default.nix b/modules/nixos/desktop/remote-desktop/default.nix index f40f7993..3ab750cd 100644 --- a/modules/nixos/desktop/remote-desktop/default.nix +++ b/modules/nixos/desktop/remote-desktop/default.nix @@ -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 + ]; } diff --git a/modules/nixos/desktop/remote-desktop/sunshine.nix b/modules/nixos/desktop/remote-desktop/sunshine.nix index b8e9bdcc..097d0a98 100644 --- a/modules/nixos/desktop/remote-desktop/sunshine.nix +++ b/modules/nixos/desktop/remote-desktop/sunshine.nix @@ -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://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; }; }