I run it as a systemd user service via home-manager. Have not spent the time to explicitly define capabilities – probably a little too broad as-is.
Very basic module I use is here:
Ah, I see what the software does now, pretty cool, thanks for trying to get this into nix.
I can also guess why it needs root privileges … it probably has do all sorts of things with the frame buffer or 3d card for video compression acceleration. or maybe not?
It’s an ‘extrarules’ option, which basically just creates ‘a symbolic link’ in /etc/blah/blah…
The nix code that setup up the extraRules could do a bit of parsing of the OPTIONS+= , and warn the users that they are going to need a related kernel module to get it to work.
However, there are very few OPTIONS that need a kernel module , then it’s probably not worth doing.
I checked the udev docs static_node= SNIP SNIP SNIP The static nodes might not have a corresponding kernel device; they are used to trigger automatic kernel module loading when they are accessed.
So, normal udev, automatically loads this driver into the kernel, I bet nix isn’t doing that.
if you create a service for sunshine and i hope they you do … you just need get the service to add this kernel module by default.
Unfortunately, after many attempts I have errors with wayfire to create a fake screen
if i add WLR_BACKENDS=headless Couldn't find matching mode 1600x2176@60 for output HEADLESS-1. Trying to use custom mode
or if i add WLR_BACKENDS=libinput,drm,headless Could not add backend: multiple renderers at the same time aren't supported failled to add backend 'headless'
I think the last one is regarding widgets/tray icons, etc. The other one I understand is for descovery in the WLAN. Anyways, I start Sunshine, open Moonlight on my phone, enter my IP and it says it can’t connect, that I might have to check the ports are open. I have this:
For the first error, believe services.avahi.publish.userServices = true is needed since you are running Sunshine as a user unit.
As for your connectivity issue, are you sure the ports are open on your firewall? Check with iptables -L or equivalent and make sure you see them? Alternatively you can try Moonlight locally and just make sure it can see the Sunshine instance.
Yep, I read through most of your config and saw the avahi config. I wasn’t using it before so I added it to mine.
About the ports, I was sure I had them open as I had the proper ports configured in the flake, but alas, I disabled the firewall and it worked!
I’m just two steps away from completely setting it up. First, it’s not opening apps! I’ll add a log in an hour or so of what’s happening, but if I execute the command to open Steam in Big Picture from the console, it works. When I do it from Moonlight, I get this:
[2023:04:24:22:48:50]: Info: Spawning [setsid steam steam://open/bigpicture] in ["/run/current-system/sw/bin"]
[2023:04:24:22:48:50]: Warning: run_unprivileged() is not yet implemented for this platform. The new process will run with Sunshine's permissions.
On the other hand, I have to work on optimizing the gaming experience. It stutters and lags playing Star Wars Fallen Order with an 6800xt in 1080p at medium settings, so I think there is room to improve.
Anyways, thanks for the package and the help! I love this from this community
[2023:06:16:21:32:42]: Info: Spawning [setsid /nix/store/b7zgnxgzmmfmwixxb9gw3m86rj5brzwb-steam/bin/steam steam://open/bigpicture] in [""]
[2023:06:16:21:32:42]: Warning: run_unprivileged() is not yet implemented for this platform. The new process will run with Sunshine's permissions.
[2023:06:16:21:32:42]: Warning: Couldn't spawn [setsid /nix/store/b7zgnxgzmmfmwixxb9gw3m86rj5brzwb-steam/bin/steam steam://open/bigpicture]: System: No such file or directory
[2
Btw, thank for sharing the avahi tip. I was having trouble figuring out why I could not find the device. I have read more about what is avahi.
Edit: I find it odd it cant find setsid as I specified the env
I’ve been trying to figure out how to get steam to load as an app without much luck. But I’m not sure where to put the above referenced code to be able to use it properly.
I’m running Sunshine as a user service using this nix config file and using the import function into the main nix config file:
Would I just be adding this to this existing file? Or do I need to create a new .nix config file. I’m fairly new to Nix in general and would appreciate any help.
Edit: This service file was mainly pulled from another one I found on github, so it may not be correct. Sunshine does start and I can connect. But I’m unable to edit the apps.json file without using a root account. I’m not using home-manager.
Create a separate file just to manage home and then import it under the right key.
(harder), use nixos to create the file but you will need to change the service to pass file_app=<generated_file> (docs) when running sunshine. Would require changing how the service runs to support additional arguments.
That helped some, I got a bit closer. Steam won’t start, but I am generating the configs via home-manager.
I got resolution switching working, but it seems steam won’t open due to a permissions error most likely…
Error from steam.txt
bwrap: Unexpected capabilities but not setuid, old file caps config?
Sunshine log:
[2023:06:21:16:07:33]: Info: Spawning [/nix/store/87mfa22rgff50l6fafclzkhy9b9s0b0a-util-linux-2.38.1-bin/bin/setsid /nix/store/jx6aiqgwvxp6kmxhwrl4ipg9971m8q8w-steam/bin/steam steam://open/bigpicture] in ["/nix/store/87mfa22rgff50l6fafclzkhy9b9s0b0a-util-linux-2.38.1-bin/bin"]
[2023:06:21:16:07:33]: Warning: run_unprivileged() is not yet implemented for this platform. The new process will run with Sunshine's permissions.
The run_unprivileged() log I also have (dont know exactly… but is not bothering me yet). Let me know if you find out how to fix it.
Regarding the bwrap: Unexpected capabilities but not setuid, old file caps config?, I am not sure but it might be related with some settings required and documented.
I am also fairly new to the scene, but can you try including the remaining setup parts ?
{
...
# Make it work for KMS.
# TODO: Should I migrate cap_sys_admin+p to CapabilityBoundingSet within the systemd?
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"
'';
}
I am under the impression that that the KMS setup is not required for X11 but does not hurt (much) having it as far as I can tell.
[2023:06:22:08:25:59]: Info: Avahi service Sunshine successfully established.
[2023:06:22:08:26:59]: Info: Executing Do Cmd: [/nix/store/v9k2l6g2hl7kb2f5dw5zl5vxbiyrw43w-libkscreen-5.27.5/bin/kscreen-doctor output.1.mode.12]
[2023:06:22:08:26:59]: Warning: run_unprivileged() is not yet implemented for this platform. The new process will run with Sunshine's permissions.
[2023:06:22:08:26:59]: Info: Spawning [/nix/store/87mfa22rgff50l6fafclzkhy9b9s0b0a-util-linux-2.38.1-bin/bin/setsid /nix/store/jx6aiqgwvxp6kmxhwrl4ipg9971m8q8w-steam/bin/steam steam://open/bigpicture] in ["/nix/store/87mfa22rgff50l6fafclzkhy9b9s0b0a-util-linux-2.38.1-bin/bin"]
[2023:06:22:08:26:59]: Warning: run_unprivileged() is not yet implemented for this platform. The new process will run with Sunshine's permissions.
[2023:06:22:08:26:59]: Info: Executing [Desktop]
[2023:06:22:08:26:59]: Info: CLIENT CONNECTED
kscreen-doctor works, but steam does not. If I run the listed command:
From the terminal, it works as expected. But if I attempt to run the same command from the root user, it does not work and outputs:
[root@workstation-01:/etc/nixos]# /nix/store/87mfa22rgff50l6fafclzkhy9b9s0b0a-util-linux-2.38.1-bin/bin/setsid /nix/store/jx6aiqgwvxp6kmxhwrl4ipg9971m8q8w-steam/bin/steam steam://open/bigpicture
[root@workstation-01:/etc/nixos]# bwrap: Can't chdir to /etc/nixos: No such file or directory
Edit:
From some additional experimentation, the problem is caused by the security wrapper. If I remove the wrapper, the application loads normally as you’d expect but then you get the cap_sys_admin+p error in sunshine and cannot connect…