From ccde8e238e69b0052325b6d0ee9249f3bfbc1b17 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Sun, 27 Apr 2025 21:12:20 +0800 Subject: [PATCH] feat(steam): add compatibility utils --- flake.lock | 59 ++++++++++++++++++++++++++++++++++++++-- flake.nix | 4 +++ hosts/nemesis.nix | 1 - modules/nixos/gaming.nix | 38 ++++++++++++++++---------- 4 files changed, 85 insertions(+), 17 deletions(-) diff --git a/flake.lock b/flake.lock index 24b5377..dd111a2 100644 --- a/flake.lock +++ b/flake.lock @@ -138,6 +138,24 @@ } }, "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_2" + }, + "locked": { + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_3": { "inputs": { "nixpkgs-lib": [ "stylix", @@ -372,6 +390,27 @@ "type": "github" } }, + "nix-gaming": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1745718727, + "narHash": "sha256-Q+8ki5/0doymTb/6yZyB1IgKy7vIkWG5IILIzw9Vz1U=", + "owner": "fufexan", + "repo": "nix-gaming", + "rev": "f42092f4379fe71bf810a71c1c33f1f807b97746", + "type": "github" + }, + "original": { + "owner": "fufexan", + "repo": "nix-gaming", + "type": "github" + } + }, "nix-index-database": { "inputs": { "nixpkgs": [ @@ -438,9 +477,24 @@ "type": "github" } }, + "nixpkgs-lib_2": { + "locked": { + "lastModified": 1743296961, + "narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "nur": { "inputs": { - "flake-parts": "flake-parts_2", + "flake-parts": "flake-parts_3", "nixpkgs": [ "stylix", "nixpkgs" @@ -463,7 +517,7 @@ }, "nvf": { "inputs": { - "flake-parts": "flake-parts", + "flake-parts": "flake-parts_2", "flake-utils": [ "flake-utils" ], @@ -498,6 +552,7 @@ "hyprcloser": "hyprcloser", "hyprshaders": "hyprshaders", "impermanence": "impermanence", + "nix-gaming": "nix-gaming", "nix-index-database": "nix-index-database", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", diff --git a/flake.nix b/flake.nix index de5e657..e88616c 100644 --- a/flake.nix +++ b/flake.nix @@ -69,6 +69,10 @@ inputs.nixpkgs.follows = "nixpkgs"; url = "github:nix-community/nix-index-database"; }; + nix-gaming = { + inputs.nixpkgs.follows = "nixpkgs"; + url = "github:fufexan/nix-gaming"; + }; nvf = { inputs = { flake-utils.follows = "flake-utils"; diff --git a/hosts/nemesis.nix b/hosts/nemesis.nix index b510ec3..3ec8932 100644 --- a/hosts/nemesis.nix +++ b/hosts/nemesis.nix @@ -9,5 +9,4 @@ hardware-config.cpu = "amd"; hardware-config.gpu = "nvidia"; gaming.steam.enable = true; - gaming.steam.enableGamescope = true; } diff --git a/modules/nixos/gaming.nix b/modules/nixos/gaming.nix index 13d7f21..c6717fa 100644 --- a/modules/nixos/gaming.nix +++ b/modules/nixos/gaming.nix @@ -2,6 +2,7 @@ config, lib, pkgs, + inputs, ... }: let @@ -9,34 +10,43 @@ let cfg = config."${moduleName}"; in { + imports = [ + inputs.nix-gaming.nixosModules.platformOptimizations + ]; + options = { "${moduleName}" = { steam = { enable = lib.mkEnableOption "Enable Steam."; - enableGamescope = lib.mkEnableOption "Enable the gamescope compositor."; }; }; }; config = lib.mkMerge [ (lib.mkIf cfg.steam.enable { - programs.steam = { - enable = true; - remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play - protontricks.enable = true; - dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server - localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers + programs = { + steam = { + enable = true; + remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play + protontricks.enable = true; + dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server + localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers + gamescopeSession.enable = true; + extraCompatPackages = with pkgs; [ proton-ge-bin ]; + platformOptimizations.enable = true; + }; + gamescope = { + enable = true; + capSysNice = true; + }; + gamemode.enable = true; }; environment.systemPackages = with pkgs; [ steam-run + wineWowPackages.stable + wine64 + wineWowPackages.waylandFull ]; }) - (lib.mkIf cfg.steam.enableGamescope { - programs.steam.gamescopeSession.enable = true; - programs.gamescope = { - enable = true; - capSysNice = true; - }; - }) ]; }