Error: The option `programs.steam' does not exist

Hey there,

I don’t know what am I doing wrong here ? when I try to add programs.steam.enable = true;, the compiler say me that the option don’t exists, but it work for programs.home-manager.enable = true; ?

I don’t really know what’s wrong here, if someone can explain it would be kind
there is my nix config for context.

there is the error :

error:
       … while evaluating a branch condition

         at /nix/store/dk2rpyb6ndvfbf19bkb2plcz5y3k8i5v-source/lib/lists.nix:125:9:

          124|       fold' = n:
          125|         if n == len
             |         ^
          126|         then nul

       … while calling the 'length' builtin

         at /nix/store/dk2rpyb6ndvfbf19bkb2plcz5y3k8i5v-source/lib/lists.nix:123:13:

          122|     let
          123|       len = length list;
             |             ^
          124|       fold' = n:

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `programs.steam' does not exist. Definition values:
       - In `/nix/store/yjp62hrl0pbcliiz0skpz01csnm0xkg3-source/home/default.nix':
           {
             enable = {
               _type = "if";
               condition = true;
               content = true;
           ...

PS: I’m really new, it’s been only one week since I started using NixOS, so if there is anything I’m doing wrong don’t hesitate to tell me

Home Manager’s options are documented here; it’s a different list from NixOS’s options. They use the same option system but the two projects each have their own set of option definitions. There’s no programs.steam in Home Manager.

Enabling Steam system-wide in NixOS optionally does some system configuration that Home Manager doesn’t have the privileges to do, like opening some firewall ports and configuring some OpenGL stuff. I don’t use Steam but you should be able to simply add pkgs.steam to Home Manager’s home.packages if you’re willing to handle any needed system configuration manually (you might not have to).

You need to put programs.steam.enable = true; in your configuration.nix file, not in home.nix. That will install steam system-wide rather than as a specific user.
It’s also the one way I’ve personally found Steam to run without any issues.

So I installed steam system-wide instead, it seems installed but I can’t run it ?

$ steam
The program 'steam' is not in your PATH. You can make it available in an
ephemeral shell by typing:
  nix-shell -p steamPackages.steam-fhsenv-without-steam

any idea why ? (btw I want to avoid as much as possible nix-shell for reproducibility)

What do you mean by “installed steam system-wide”? Did you put programs.steam.enable = true; in your system configuration, and then run sudo nixos-rebuild switch?

nevermind, it’s installed I have put something like that before :

programs.steam.enable = config.packages.games.enable;

but not seems work, so I just put :

programs.steam.enable = true;

sorry, I’m too dumb, but do you have any other solution how to enable it dynamically with something like mkIf ?

Hey, if you are enabling steam through Homemanager and want to access the global configuration, you will need to use osConfig and not config, as the latter is the home-manager configuration.

But if in the global context (outside of HM) using config is correct

edit:

for clarity

{ osConfig, pkgs, lib, ... }:
{
  programs.steam.enable = osConfig.packages.games.enable;
}

or

osConfig.packages.games.enable

1 Like

This is incorrect, since programs.steam is under NixOS, not HM.
And mkIf with a boolean to set a boolean seems… redundant?

Where did you define this packages.games option? In the system config, or the HM config?

I wrongly assumed HM also had a steam module

OP defined packages.games in the system config, specifically here dotfiles/hosts/laptop-lenovo-nixos/config.nix at bfaf1d97817f3ee22a323b2e030a74167c64455d · ALEZ-DEV/dotfiles · GitHub

Thanks for the link. Then there’s the cause. packages.games.enable is set to false, hence programs.steam.enable took on that same value.

in their other nix system they did set it to true: dotfiles/hosts/omen-laptop/config.nix at bfaf1d97817f3ee22a323b2e030a74167c64455d · ALEZ-DEV/dotfiles · GitHub

The issue would then be that
A. config instead of osConfig is used (which doesnt matter because of B)
B. steam is activated via HM and not the System config (see dotfiles/home/default.nix at bfaf1d97817f3ee22a323b2e030a74167c64455d · ALEZ-DEV/dotfiles · GitHub)

So moving steam to the system config would fix everything

1 Like