../declare-your-steam-launch-options

declare your steam launch options

the steam client allows users to specify "launch options" for each of their games. These can be used to specify environmental variables, arguments, options and even wrapper commands

launch options are typically used to troubleshoot, optimize performance, configure games or enable features, for example I use the following launch options for vrchat:

env -u TZ PRESSURE_VESSEL_FILESYSTEMS_RW="$XDG_RUNTIME_DIR/wivrn/comp_ipc" %command%

these are powerful, however over time you end up with a lot of these launch options you've either set up yourself, or stolen from the internet. either way you're going to forget them, and inevitably have to rediscover how you got "once human" working after you reinstall steam, or move to a different computer

steam-localconfig-nix

this is where my shiny new home-manager module steps in! steam-localconfig-nix is a project that allows you to manage steam localconfig options right from your nixos configuration, including launch options for games

using the vrchat example from earlier, my configuration would look like:

programs.steam.localConfig = {
  enable = true;

  users."875898227" = {
    launchOptions = {
      "438100" = ''env -u TZ PRESSURE_VESSEL_FILESYSTEMS_RW="$XDG_RUNTIME_DIR/wivrn/comp_ipc" %command%'';
    };
  };
};

here i enabled steam-launch and, for my steam user's localconfig, specified the launch options for vrchat's app id

and that's it! enjoy your declarative launch options <3

please keep in mind, this is in early development, and is unstable. use with caution! github:different-name/steam-localconfig-nix

how it works

steam stores launch options (and a bunch of other data) in a file called localconfig.vdf. this file is in valve's KeyValue format and can be found in your userdata config folder:

$XDG_DATA_HOME/Steam/userdata/<userid>/config/

steam-localconfig-nix converts your launch options configuration into a json file, which is passed on to the steamlc-patcher program, a python script that uses the srctools library to parse and modify localconfig.vdf

steamlc-patcher checks the contents of localconfig.vdf and only writes changes if needed. this is important, because steam must be closed for any written changes to persist. steam-localconfig-nix provides the closeSteam option, which will automatically stop steam whenever a change must be written