Starting Steam automatically in background


I am trying to declaratively start Steam automatically on boot in the background in configuration.nix. I am trying to do this via a custom systemd service. I can’t get running, though. Am I just doing it wrong?

Here’s what I tried:

  #Start Steam automatically = {
    enable = true;
    description = "Starts Steam automatically in background at boot";
    serviceConfig = {
      ExecStart = "steam -nochatui -nofriendsui -silent";
1 Like

There is a steam option that already does this for you in Settings > Interface > Run Steam when my computer starts

I don’t know whether this will work for other DEs, but in Gnome it creates a desktop file for Steam in ~/.config/autostart, which you can modify its executable to Exec=steam -nochatui -nofriendsui -silent

If this doesn’t work, you might want to look at how your DE autostarts programs and do it that way.

Sorry, but this is not declarative, and I would like a declarative solution. Thanks!

Oops, missed that point :sweat_smile:

But it’s just a file, you can just declaratively define it, for example with home-manager:

home = {
  file = {
      ".config/autostart/steam.desktop".text = ''
        [Desktop Entry]
        Exec=steam -nochatui -nofriendsui -silent

though… this has a disadvantage compared to the original attempt: systemd can be instructed to automatically restart steam if it crashes

on my htpc/gaming rigs i run kodi and steam in a systemd user service and this improved the situation for my kids

1 Like

You certainly make a valid point. I wanted to try this out for myself with the following service: = {
    enable = true;
    description = "Open Steam in the background at boot";
    serviceConfig = {
      ExecStart = "${pkgs.steam} -nochatui -nofriendsui -silent %U";
      wantedBy = [ "" ];
      Restart = "on-failure";
      RestartSec = "5s";

But I get this error:

nixos systemd[2638]: Started Open Steam in the background at boot.
nixos systemd[2638]: steam.service: Main process exited, code=exited, status=203/EXEC
nixos systemd[2638]: steam.service: Failed with result 'exit-code'.

Am I doing something wrong here?

"${pkgs.steam}" is a path to directory where steam package is stored, you want "${pkgs.steam}/bin/steam" instead

1 Like

Yup, you’re right :person_facepalming: