I finally got it working and was able to run a few games in Ultra with quite a good experience ! ![]()
Autologin issue was only with lightdm. Switching to gdm made it work. I’m not sure what caused the issue with lightdm but journactl errors seemed to indicate that desktop session service started before X session was ready, causing it to fail and logout.
Using gdm display manager with gnome desktop manager works like a charm now:
services.xserver = {
enable = true;
videoDrivers = ["nvidia"];
displayManager.gdm.enable = true;
displayManager.defaultSession = "gnome";
displayManager.autoLogin.enable = true;
displayManager.autoLogin.user = "sunshine"; # user must exists
desktopManager.gnome.enable = true;
}
Configuring a user systemd service allow server to start
security.wrappers.sunshine = {
owner = "root";
group = "root";
capabilities = "cap_sys_admin+p";
source = "${pkgs.sunshine}/bin/sunshine";
};
# Inspired from https://github.com/LizardByte/Sunshine/blob/5bca024899eff8f50e04c1723aeca25fc5e542ca/packaging/linux/sunshine.service.in
systemd.user.services.sunshine = {
description = "Sunshine server";
wantedBy = [ "graphical-session.target" ];
startLimitIntervalSec = 500;
startLimitBurst = 5;
partOf = [ "graphical-session.target" ];
wants = [ "graphical-session.target" ];
after = [ "graphical-session.target" ];
serviceConfig = {
ExecStart = "${config.security.wrapperDir}/sunshine ${configFile}/config/sunshine.conf";
Restart = "on-failure";
RestartSec = "5s";
};
};
Fully working config as of now: https://github.com/PierreBeucher/cloudy-sunshine/blob/6813e5690caea388386999de93bb857e95fa1e62/provision/configuration-sunshine.nix
Only client side, the moonlight-qt package is missing h264/265 codecs. Moonlight kept complaining despite installing x265, x264 and other packages that supposedly provide codecs, I’ll create an issue. However using Flatpak com.moonlight_stream.Moonlight works on a NixOS client - a bit dirty but works well for now.