Following the guide on Nvidia - NixOS Wiki, I set everything up. However, at the step of automatizing Steam offload launching, I tried to run $ sed 's/^Exec=/&nvidia-offload /' /run/current-system/sw/share/applications/steam.desktop > ~/.local/share/applications/steam.desktop
as instructed, to which received sed: can't read /run/current-system/sw/share/applications/steam.desktop: No such file or directory.
Everything before that seemingly went well. I have the Steam nix package installed (through declaration in config.nix), I ran it, and I already launched games with it.
Another thing is that this is my first contact with scripts, and I don’t understand some of the terminology and don’t know of some steps implied. Reading this on the wiki:
What does “wrapping a script around an executable” mean? I am pretty sure the code has to be inserted into a file, but which one? Given the example script, how do I know which parts are to be altered for my programs and in what way?
You should be able to use nvidia-offload for all programs. For example, nvidia-offload steam in your console should just work.
But…
You probably don’t want to do that. The steam client itself isn’t going to benefit much from improved 3d acceleration capabilities. You likely instead want to add this to the launch options of all your games, i.e. go to your library, click the game, find the LAUNCH OPTIONS heading under general, and then set:
nvidia-offload %command%
Then your steam client will use the iGPU, which will be better at decoding videos that play there and whatnot, while using less energy, and your games will use the dGPU, which will give the performance to run them.
Unfortunately this cannot be set declaratively to my knowledge. Perhaps there’s some way to at least generally do it for all games with steam, but I’m unaware of such a setting.
I have it enabled, but have no idea how to use it. It says that hardware.nvidia.prime.offload.enableOffloadCmd “[a]dds a nvidia-offload convenience script to environment.systemPackages”. Is environment.systemPackages the entry in configuration.nix or a directory? If it’s a directory, how do I access it?
find the LAUNCH OPTIONS heading under general, and then set:
nvidia-offload %command%
this worked very well, thank you! However, when I try to offload Apex Legends run through Proton (no native version available) a window opens and stays black for a while, then just closes without any input from me. Launching in the same way through Proton on the iGPU works. Searched for a solution, but to no success yet.
The option. Setting that other option already added nvidia-offload to it; you don’t need to do anything else with it. As I said, the wiki is outdated.
It will put the nvidia-offload script in the $PATH env variable, and since doing the launch options thing is working it’s already there and everything is set up correctly.
I assume you mean proton, right? ProtonDB is the website that records quirks around running non-native steam games with proton.
Yeah, unfortunate… There will be some games that don’t work well, and I have neither the game nor an offload setup to debug this for you. I’d recommend:
Start steam from the command line; it will then write logs to the terminal window when you launch your game, which will help figuring out what’s wrong.
Look at the ProtonDB comments for advice, especially ones that have similar hardware as you do.
Thank you for clarifying that it’s set up correctly. I would still like to ask a question to get a better understanding.
The option. Setting that other option already added nvidia-offload to it; you don’t need to do anything else with it. […]
It will put the nvidia-offload script in the $PATH env variable
The option in configuration.nix stays the same. Does the option exist somewhere else where the change in it occurs?
I assume you mean proton, right?
Yeah, sorry. I made edits for future readers.
I will try to debug it. Appreciate your directions very much!
And a lot of other places where different changes occur
All declarations of nixpkgs options are merged together when you evaluate your configuration, including ones hidden in nixpkgs. For lists, all of the instances will be concatenated together, other options may give you errors telling you to use lib.mkForce to override them. Often when you use a *.enable option the module being enabled will set environment.systemPackages to include its package, and do some other miscellaneous setup (like add systemd units, configuration files, …), all using other, less abstract options defined in nixpkgs.
This goes on recursively until you arrive at the “activation script”, which is a big bash script that makes all the changes the various options imply, and is run every time you run nixos-rebuild switch or boot the system.
Note that the actual options are of course not literally written out in a merged form to a file you can read. This happens all in memory, when nix evaluates the modules, and is completely transparent to you. The closest you can get to seeing this behavior is using the lib.debug.trace* functions.
You can get this merge behavior and split your own configuration.nix into multiple files using imports, by the way.