nix-dotfiles/modules/software/distractions/steam.nix
2026-06-08 21:21:04 -07:00

75 lines
2.1 KiB
Nix

{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.modules.software.distractions.steam;
in {
options.modules.software.distractions.steam = {
enable = mkEnableOption "Enable Steam, the game distribution software";
gamescope = mkEnableOption "Enable gamescope, a mini-compositor tuned for games";
session = mkEnableOption "Enable a Steam Deck-like session powered by gamescope";
};
config = mkIf cfg.enable {
programs.steam = {
enable = true;
gamescopeSession.enable = cfg.session;
package = pkgs.steam.override {
# required for programs to run sometimes
# see: https://github.com/NixOS/nixpkgs/issues/162562#issuecomment-1229444338
extraPkgs = (pkgs: (optional cfg.gamescope pkgs.gamescope) ++ (with pkgs; [
libXcursor
libXi
libXinerama
libXScrnSaver
libpng
libpulseaudio
libvorbis
stdenv.cc.cc.lib
libkrb5
keyutils
gperftools
]));
extraEnv = {
# https://github.com/gloriouseggroll/proton-ge-custom
PROTON_USE_WAYLAND = "1";
PROTON_USE_WOW64 = "1";
};
};
extraCompatPackages = with pkgs; [ proton-ge-bin ];
protontricks.enable = true;
# explicitly allow all the ports to open up
localNetworkGameTransfers.openFirewall = true;
remotePlay.openFirewall = true;
dedicatedServer.openFirewall = true;
};
# TODO: make it so that this wrapper encompasses steam's gamescope
# this would make it so we don't have to put the config each time, like this:
# gamescope --expose-wayland --adaptive-sync -f -W 1920 -H 1080 -w 1920 -h 1080 -- %command%
programs.gamescope = {
enable = cfg.gamescope;
args = [
"--expose-wayland"
"--adaptive-sync"
"-f"
"-W 1920"
"-H 1080"
"-w 1920"
"-h 1080"
];
};
# enable windows NT sync primitive driver (semaphores, mutexes, etc.)
# improves performance on wine 11+ and proton 11+
boot.kernelModules = [ "ntsync" ];
user.packages = with pkgs; [ steam-run ];
};
}