Linux Distros

How to Install Steam on NixOS?

When installing things on NixOS, you need to have a package in the right format on the web page. Steam is available, but some quirks may trip you up when you try to install it. You will hear more about this here.

In particular, it is a non-free software package, so you must enable this option. You will also need to handle the ‘glXChooseVisual failed’ problem. The process will work one way in NixOS and another way on other distributions. It is more complex with just the Nix package manager.

What is Steam?

Most people who come already know this but let’s cover it here anyway. Steam is a platform and market for games and gamers. It started as a way to update your game from Valve. It was the only one for the first time in life. As the company added more games, they also added them to the platform. With so many games available, they rebuilt it to be a market place and community platform. You can now both play and buy games and stay in touch with fellow gamers on the platform. Given all this, of course, you want to have it installed on your NixOS system.

Installing the Main Executable

There have been some problems with Steam on NixOS in the past. The problems were solved but still require some extra actions compared to other packages.

One issue is that this is not free software. Second, the packages use Glx of the 32-bit variant, something that is not clearly reflected in the packages. These two issues need to be addressed in the setup of the package manager: Nix or NixOS configuration (.nix) file. The actual solution was to set the dri support 32bit value to true. There were a few others, but thanks to a new module from Maciej Krüger, you can now just add the module with the code below.

programs.steam.enable = true;
nixpkgs.config.allowNonFree = true;

This is a module that has solved several problems with some quirks of the Steam software. Once you have this set correctly, you can run the install. If you are interested, the below code is from the commit that adds the module to make it happen.

{ config, lib, pkgs, ... }:

with lib;

  cfg = config.programs.steam;
in {
  options.programs.steam.enable = mkEnableOption "steam";

  config = mkIf cfg.enable {
    hardware.opengl = { # this fixes the "glXChooseVisual failed" bug, context:
      enable = true;
      driSupport32Bit = true;

    # optionally enable 32bit pulseaudio support if pulseaudio is enabled
    hardware.pulseaudio.support32Bit = config.hardware.pulseaudio.enable;

    hardware.steam-hardware.enable = true;

    environment.systemPackages = [ pkgs.steam ];

  meta.maintainers = with maintainers; [ mkg20001 ];

As you can see in the code, it activates the support for 32-bit direct rendering and audio. It also adds the package ‘pkgs.steam’, which is the main Steam package. With the earlier configuration, you should get the whole system up and running at the next rebuild switch. Once you have saved your configuration, run:

$ nixos-rebuild switch

For most of you, this will allow the install to go forward. You now need to make sure you have enough disk space for the install. Also the games you will install need disk space too.

hardware.opengl.driSupport32Bit = true;

If things go wrong, use:

$ strace steam

There are many other optional packages to install if you have any special needs or desires.

nixpkgs.steam-run (steam-run)

Why do you need steam-run? Steam-run makes it possible to run using NixOS libraries instead of the ones Steam provides. This may work better when you want to run games that expect a regular Linux system beneath. Some games need patching to run, using the Steam environment. The reason is that only the Steam provided games are built for a closed environment. To use these, add the steam-run or steam-run-native to your configuration file.

environment.systemPackages = with pkgs; [

You can also use steam-run directly as a command, like this:

$ steam-run ./

This will run the game in a Steam environment directly.

Missing Dependencies

Some games may need dependencies that NixOS does not automatically provide. To fix this, you can add them to the configuration file under systemPackages.

environment.systemPackages = with pkgs; [
  (steam.override { extraPkgs = pkgs: [ mono gtk3 gtk3-x11 libgdiplus zlib ];
nativeOnly = true; }).run
  (steam.override { withPrimus = true; extraPkgs = pkgs: [ bumblebee glxinfo ];
nativeOnly = true; }).run
  (steam.override { withJava = true; })

The above code adds dependencies for many cases. You will pick the ones you need yourself, of course. You can also look for other dependencies that may be missing. However, you will be on your own if you do, so be prepared to use the terminal to start and trace it when you ask for help on the different support forums.

Other Useful Packages

You also have some special packages that may help you with some issues.

nixpkgs.steamcmd (steamcmd)

This package adds Steam command-line tools. You can use this for installing software and running your own servers; some tasks can be automated.

You also have many other packages available. To use them, you add them to your packages and rebuild. The currently available ones are below:

nixpkgs.kodiPlugins.steam-launcher (kodi-plugin-steam-launcher)

Launch Steam in Big Picture Mode from Kodi

nixpkgs.pidgin-opensteamworks (pidgin-opensteamworks)

Plugin for Pidgin 2.x, which implements Steam Friends/Steam IM compatibility

nixpkgs.bitlbee-steam (bitlbee-steam)

Steam protocol plugin for BitlBee

nixpkgs.eidolon (eidolon-1.4.6)

A single TUI-based registry for drm-free, wine, and steam games on Linux, accessed through a rofi launch menu

nixpkgs.kodiPlugins.steam-controller (kodi-plugin-peripheral.steamcontroller)

Binary addon for the steam controller

nixpkgs.matterbridge (matterbridge-1.18.0)

The simple bridge among Mattermost, IRC, XMPP, Gitter, Slack, Discord, Telegram, Rocket.Chat, Hipchat(via XMPP), Matrix, and Steam

nixpkgs.steamcontroller (steamcontroller)

A standalone Steam controller driver (sc-controller-0.4.7)

User-mode driver and GUI for Steam controller and other controllers


Steam presents a small problem because a large part of the platform and some games still require 32-bit libraries, and you need to enable that. Hopefully, you have gotten your answer here. If not, you may ask on the forums! NixOS is extremely versatile, but getting to grips with the Nix language is a chore. When you switch, make sure you have some fundamental understanding of the language to avoid long winding searches for solutions. You should be able to come up with many yourself with enough grasp of the Nix language.

About the author

Mats Tage Axelsson

I am a freelance writer for Linux magazines. I enjoy finding out what is possible under Linux and how we can all chip in to improve it. I also cover renewable energy and the new way the grid operates. You can find more of my writing on my blog.