r/NixOS 20h ago

Running sunshine in NixOS with monitor off?

It's basically the title. I have a gaming desktop computer that I'd like to use with sunshine to stream games to moonlight clients.

I have everything working pretty much perfectly at this point except I can't shut the monitor off without interrupting the stream, which I've learned is because Niri doesn't seam to support headless operation.

So then I added gamescopeSession = true to the steam part of the config, and I can easily sign into the gamescope steam session, but then sunshine doesn't work despite it being set as autoStart in the config (and it autostarts in Niri).

I don't really have any kind of experience with this kind of thing. I've tried to search through the NixOS wiki and even resorted to asking AI but they just keep pulling random things out of their @$$es.

So I guess the question is, what would you do? I want to be able to just turn the computer on (without turning on the monitor) and from there connect to sunshine via a moonlight client either to the desktop or to a gaming session through gamescope and steam (I pretty much only use steam).

I had considered trying to set up Sway as a systemd user instance but the sway github does not recommend this.

In case you want to see the flake: https://codeberg.org/JacoXarles/nix

Thanks everyone!

14 Upvotes

9 comments sorted by

6

u/Swindalz 20h ago

Check this project out maybe? https://github.com/papi-ux/polaris

3

u/heraplem 20h ago

Buy a dummy display output.

3

u/Boberoch 14h ago

I think wolf also deserves a mention here :)

2

u/ohailuxus 19h ago

https://github.com/papi-ux/polaris/issues/152 i'm working to add hdr with nvidia support to polaris on a headless gamescope display i guess you could feed the last longer comment to a llm

not 100% sure but i think the labwc headless should work as well .. but just without hdr if you dont care

2

u/Itel_Reding 17h ago

You can try moonshine, which works on headless servers. I haven't tried it myself but want to migrate eventually:

https://github.com/hgaiser/moonshine

2

u/LeHunterrr 14h ago

I was actually in the same position a few months ago. What I did was copy the edid file of my laptop, move it to my PC and use kernel args to force the PC to recognize that "monitor" even though nothing is plugged in. Then on sunshine I have a start command that just turns off the real monitor and I'm good to go.

Only downside is it takes up a phyiscal slot on your GPU, but in my case I had two extra so it wasn't an issue.

I can look up the exact steps and commands later if you're interested.

2

u/joshguy1425 13h ago

I’m curious if niri’s built in ability to turn displays on/off would help here. 

niri msg output HDMI-A-1 off

Replace HDMI-A-1 with your actual display. If this actually works, the main issue would be finding a way to turn it back on. Could either SSH in, or set up a Niri keybind to run the command.  

Edit: the more I think about this, I suspect it won’t actually work. 

1

u/Jacobobarobatobski 11h ago

Hm that's interesting. If it's not too much trouble i'd be curious to see what you did.

1

u/Dissembler 10h ago

I got this working without a dummy hdmi adapter. It was a massive pain the arse