Sunshine module does not autostart
Describe the bug
sunshine service does not start once enabled
Steps To Reproduce
Steps to reproduce the behavior:
{
services.sunshine = {
enable = true;
openFirewall = true;
# capSysAdmin = true;
};
}
Expected behavior
for the service to autostart, I saw the autostart option but I believe thats set to true by default.
Screenshots
nixos-config on main [!?]
❯ systemctl --user status sunshine
○ sunshine.service - Self-hosted game stream host for Moonlight
Loaded: loaded (/etc/systemd/user/sunshine.service; enabled; preset: enabled)
Active: inactive (dead)
nixos-config on main [!?]
❯ journalctl --user -u sunshine
-- No entries --
Notify maintainers
@tarantoj @Scrumplex
Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.
nixos-config on main [!?]
❯ nix-shell -p nix-info --run "nix-info -m"
- system: `"x86_64-linux"`
- host os: `Linux 6.6.48, NixOS, 24.05 (Uakari), 24.05.4469.6e99f2a27d60`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.18.5`
- channels(root): `"home-manager-24.05.tar.gz, nixos-24.05"`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
Add a :+1: reaction to issues you find important.
Also does enabling services.sunshine.capSysAdmin mean that the service runs as root? or just has some root perms?
Do you have the autoStart option set to true? Looks like that will make it start once you start up your graphical session.
Do you have the autoStart option set to true? Looks like that will make it start once you start up your graphical session.
After restarting the warning I got about not having access to capsysadmin also disappeared. So what happened was
- I added sunshine like the bug report above
- I accessed the webui, and saw the warnings about capsysadmin
- enabled capsysadmin and rebuilt, I noticed that the service did not automatically restart
- I manually restarted the service and the warning seemed to have gone away.
I'm not sure if this is intended but it's weird
Yeah, can confirm the service does not automatically start after enabling.
These rules must need some work, but I'll have to read more or just start playing with it.
wantedBy = mkIf cfg.autoStart [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
wants = [ "graphical-session.target" ];
after = [ "graphical-session.target" ];
Yeah, can confirm the service does not automatically start after enabling.
These rules must need some work, but I'll have to read more or just start playing with it.
wantedBy = mkIf cfg.autoStart [ "graphical-session.target" ]; partOf = [ "graphical-session.target" ]; wants = [ "graphical-session.target" ]; after = [ "graphical-session.target" ];
Thanks I thought I was going crazy lol
Does your graphical-session.target get started? If you are not using a traditional DE, you might need to use a wrapper to start the target for you
Does your
graphical-session.targetget started? If you are not using a traditional WM, you might need to use a wrapper to start the target for you
It should have been, I use kde.
Does it start after a reboot? I use this module with Plasma, and it autostarts on boot/login for me normally.
Does it start after a reboot? I use this module with Plasma, and it autostarts on boot/login for me normally.
I haven't tested this but all I needed to do was a service restart so I assume yes.
I think this is expected behavior -- pretty the unit will not start if it's just enabled after the target is reached -- it will either need to be started manually, or the system (or DE) will need to be restarted to re-trigger everything needed for the target. @Scrumplex thoughts on if this seems reasonable?
Can confirm it does start automatically after I restart my DM. Is this default NixOS behavior? not to start a service or at least warn that it may need to be started automatically? (I believe HM adds some warnings when units need to be started which is nice.)
Can confirm it does start automatically after I restart my DM. Is this default NixOS behavior? not to start a service or at least warn that it may need to be started automatically? (I believe HM adds some warnings when units need to be started which is nice.)
It should automatically restart if a config option change requires a restart. Because if you don't you end of up "ghost" like settings that aren't in your config
IMO it would be a valid assumption to start the unit if it wasn't running yet, but this is a long standing issue with user units and NixOS. I can't find the issue that's tracking this right now
this is a long standing issue with user units and NixOS. I can't find the issue that's tracking this right now
@Scrumplex , was this it or was it somewhere else?
- https://github.com/NixOS/nixpkgs/issues/21460
this is a long standing issue with user units and NixOS. I can't find the issue that's tracking this right now
@Scrumplex , was this it or was it somewhere else?
* [systemd user-units can't be easily enabled/disabled per user #21460](https://github.com/NixOS/nixpkgs/issues/21460)
Not quite. I meant that changes to user units don't cause restarts to user services unless Home Manager (or a similar tool) is used.