Skip to content

Instantly share code, notes, and snippets.

@shiryel
Created April 1, 2026 06:22
Show Gist options
  • Select an option

  • Save shiryel/51c86667f8fec7013d450a0e18590c45 to your computer and use it in GitHub Desktop.

Select an option

Save shiryel/51c86667f8fec7013d450a0e18590c45 to your computer and use it in GitHub Desktop.
Steam Nixjail
{ lib, pkgs, ... }:
with lib;
{
nixjail.bwrap.profiles =
let
steam_common = {
dev = true;
xdg = false;
dbusProxy = {
enable = true;
user = {
# see: https://github.com/flathub/com.valvesoftware.Steam/blob/beta/com.valvesoftware.Steam.yml
owns = [
"com.steampowered.*"
];
talks = [
"org.freedesktop.Notifications"
"org.kde.StatusNotifierWatcher"
"org.freedesktop.portal.Desktop" # always required
"org.freedesktop.portal.OpenURI"
"org.freedesktop.UDisks2"
];
};
};
autoBindHome = false;
rwBinds =
[
# you can run a proton game with the TARGET: explorer.exe
# to verify if the proton is not accessing the wrong files
{ from = "/games/steam"; to = "$HOME/"; }
"/games/steam" # fixes recursive bwraping (e.g. gamescope)
"$HOME/.config/MangoHud/MangoHud.conf"
];
};
in
[
(steam_common // {
post_exec = ''-console -nochatui -nofriendsui "$@"'';
packages = f: p: with p; { _steam = steam; };
extraConfig = [
"--setenv STEAM_EXTRA_COMPAT_TOOLS_PATHS ${
lib.makeSearchPathOutput "steamcompattool" "" [
pkgs.proton-ge-bin
]
}"
"--setenv PATH ${pkgs.gamescope}/bin:$PATH"
];
})
(steam_common // {
packages = f: p: with p; {
r2modman = r2modman;
protontricks = protontricks;
steam-run-external = p.steam-run; # need to be another name to not override the one used by protontricks
gamescope-bwrap = gamescope; # to not conflict with the one used by steam
};
})
# STEAMVR ONLY
#
# REQUIRES: sudo setcap CAP_SYS_NICE+ep /games/steam/.local/share/Steam/steamapps/common/SteamVR/bin/linux64/vrcompositor-launcher
(steam_common // {
install = false;
post_exec = ''-console -nochatui -nofriendsui "$@"'';
packages = f: p: with p; {
_steam-vr = steam;
};
shareNamespace = {
pid = true;
ipc = true;
};
dbusProxy = {
enable = false;
};
})
(steam_common // {
shareNamespace = {
pid = true;
ipc = true;
};
packages = f: p: with p; { bs-manager = bs-manager; };
})
];
environment.systemPackages = with pkgs; [
(makeDesktopItem {
name = "Steam VR";
desktopName = "Steam VR";
genericName = "Steam VR";
type = "Application";
icon = "steam";
terminal = false;
mimeTypes = [ "x-scheme-handler/steam" "x-scheme-handler/steamlink" ];
categories = [ "Network" "FileTransfer" "Game" ];
exec = "${_steam-vr}/bin/steam %U";
})
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment