Sunshine: Difference between revisions

From NixOS Wiki
import from old wiki
 
Devusb (talk | contribs)
m fix formatting error
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
This page is intended to explain how to use Sunshine, an open-source implementation of Nvidia’s Moonlight game streaming application.
This page is intended to explain how to use Sunshine, an open-source implementation of NVIDIA’s GameStream protocol.


== Install ==
== Install ==
To install Sunshine and enable to for use you will need to open up network ports as shown here:{{file|/etc/nixos/configuration.nix|nix|<nowiki>
 
 
To install Sunshine and enable it you can use the following snippet:
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
  services.sunshine = {
    enable = true;
    autoStart = true;
    capSysAdmin = true; # only needed for Wayland -- omit this when using with Xorg
    openFirewall = true;
  };
</nowiki>}}
 
 
For manual Firewall configuration you can open network ports as shown here:
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
networking.firewall = {
networking.firewall = {
   enable = true;
   enable = true;
Line 14: Line 30:


== Connecting to the host ==
== Connecting to the host ==
Before moving forward I would strongly recommend restarting the computer and making sure you start Sunshine once you reboot.
 
When installed via the NixOS module, Sunshine is configured as a Systemd user unit, and will start automatically on login to a graphical session. Note that a logout/login or restart may be required for Sunshine to start after initially adding it to your configuration due to limitations of NixOS' handling of user units with <code>nixos-rebuild</code>. 
 
If <code>services.sunshine.autoStart</code> is set to <code>false</code>, Sunshine needs to be started with the <pre>sunshine</pre> command.


You may have to manually add the host running Sunshine to your Moonlight client. This, thankfully, is not hard to do.
You may have to manually add the host running Sunshine to your Moonlight client. This, thankfully, is not hard to do.
Line 22: Line 41:
<code><Host IP>:47989</code>
<code><Host IP>:47989</code>


If this doesn’t work you should double check the port in the Sunshine’s WebGUI. You can access this from the Host PC in a web browser <code>localhost:47990</code>
If this doesn’t work you should double check the port in the Sunshine’s WebGUI. You can access this from the Host PC in a web browser <code>https://localhost:47990</code>


If this doesn’t work, make sure Sunshine is actually running. You can do this by running <code>sunshine</code> in a terminal.
== Attribution ==
 
A substantial amount of the above came from [https://www.reddit.com/r/NixOS/comments/1bq2bx4/beginners_guide_to_sunshine_gamedesktop_streaming/ this fairly wonderful guide] posted to Reddit.
== Troubleshooting ==
If once you run Sunshine you may see a lot of error messages. Some of these don’t necessarily prevent Sunshine from working, for ones that do the following section hopes to solve those problems.


=== Error: Failed to gain CAP_SYS_ADMIN ===
This can be fixed by using the code as follows:{{file|/etc/nixos/configuration.nix|nix|<nowiki>
security.wrappers.sunshine = {
        owner = "root";
        group = "root";
        capabilities = "cap_sys_admin+p";
        source = "${pkgs.sunshine}/bin/sunshine";
};</nowiki>}}


=== Error: avahi::entry_group_new() failed: Not permitted ===
[[Category:Applications]]
The following lines can help with this:{{file|/etc/nixos/configuration.nix|nix|<nowiki>
[[Category:Gaming]]
services.avahi.publish.enable = true;
services.avahi.publish.userServices = true;</nowiki>}}
 
== Attribution ==
A substantial amount of the above came from [https://www.reddit.com/r/NixOS/comments/1bq2bx4/beginners_guide_to_sunshine_gamedesktop_streaming/ this fairly wonderful guide] posted to Reddit:

Latest revision as of 16:41, 26 September 2024

This page is intended to explain how to use Sunshine, an open-source implementation of NVIDIA’s GameStream protocol.

Install

To install Sunshine and enable it you can use the following snippet:

/etc/nixos/configuration.nix
  services.sunshine = {
    enable = true;
    autoStart = true;
    capSysAdmin = true; # only needed for Wayland -- omit this when using with Xorg
    openFirewall = true;
  };


For manual Firewall configuration you can open network ports as shown here:

/etc/nixos/configuration.nix
networking.firewall = {
  enable = true;
  allowedTCPPorts = [ 47984 47989 47990 48010 ];
  allowedUDPPortRanges = [
    { from = 47998; to = 48000; }
    { from = 8000; to = 8010; }
  ];
};

Connecting to the host

When installed via the NixOS module, Sunshine is configured as a Systemd user unit, and will start automatically on login to a graphical session. Note that a logout/login or restart may be required for Sunshine to start after initially adding it to your configuration due to limitations of NixOS' handling of user units with nixos-rebuild.

If services.sunshine.autoStart is set to false, Sunshine needs to be started with the

sunshine

command.

You may have to manually add the host running Sunshine to your Moonlight client. This, thankfully, is not hard to do.

Simply press the button that says Add Host Manually, from there you will need to input the following (replace <Host IP> with your Host’s IP address):

<Host IP>:47989

If this doesn’t work you should double check the port in the Sunshine’s WebGUI. You can access this from the Host PC in a web browser https://localhost:47990

Attribution

A substantial amount of the above came from this fairly wonderful guide posted to Reddit.