feat(steam): add compatibility utils

This commit is contained in:
Mohammad Rafiq 2025-04-27 21:12:20 +08:00
parent b62ca97ccb
commit ccde8e238e
No known key found for this signature in database
4 changed files with 85 additions and 17 deletions

59
flake.lock generated
View file

@ -138,6 +138,24 @@
} }
}, },
"flake-parts_2": { "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": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
"stylix", "stylix",
@ -372,6 +390,27 @@
"type": "github" "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": { "nix-index-database": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -438,9 +477,24 @@
"type": "github" "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": { "nur": {
"inputs": { "inputs": {
"flake-parts": "flake-parts_2", "flake-parts": "flake-parts_3",
"nixpkgs": [ "nixpkgs": [
"stylix", "stylix",
"nixpkgs" "nixpkgs"
@ -463,7 +517,7 @@
}, },
"nvf": { "nvf": {
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-parts": "flake-parts_2",
"flake-utils": [ "flake-utils": [
"flake-utils" "flake-utils"
], ],
@ -498,6 +552,7 @@
"hyprcloser": "hyprcloser", "hyprcloser": "hyprcloser",
"hyprshaders": "hyprshaders", "hyprshaders": "hyprshaders",
"impermanence": "impermanence", "impermanence": "impermanence",
"nix-gaming": "nix-gaming",
"nix-index-database": "nix-index-database", "nix-index-database": "nix-index-database",
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",

View file

@ -69,6 +69,10 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
url = "github:nix-community/nix-index-database"; url = "github:nix-community/nix-index-database";
}; };
nix-gaming = {
inputs.nixpkgs.follows = "nixpkgs";
url = "github:fufexan/nix-gaming";
};
nvf = { nvf = {
inputs = { inputs = {
flake-utils.follows = "flake-utils"; flake-utils.follows = "flake-utils";

View file

@ -9,5 +9,4 @@
hardware-config.cpu = "amd"; hardware-config.cpu = "amd";
hardware-config.gpu = "nvidia"; hardware-config.gpu = "nvidia";
gaming.steam.enable = true; gaming.steam.enable = true;
gaming.steam.enableGamescope = true;
} }

View file

@ -2,6 +2,7 @@
config, config,
lib, lib,
pkgs, pkgs,
inputs,
... ...
}: }:
let let
@ -9,34 +10,43 @@ let
cfg = config."${moduleName}"; cfg = config."${moduleName}";
in in
{ {
imports = [
inputs.nix-gaming.nixosModules.platformOptimizations
];
options = { options = {
"${moduleName}" = { "${moduleName}" = {
steam = { steam = {
enable = lib.mkEnableOption "Enable Steam."; enable = lib.mkEnableOption "Enable Steam.";
enableGamescope = lib.mkEnableOption "Enable the gamescope compositor.";
}; };
}; };
}; };
config = lib.mkMerge [ config = lib.mkMerge [
(lib.mkIf cfg.steam.enable { (lib.mkIf cfg.steam.enable {
programs.steam = { programs = {
enable = true; steam = {
remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play enable = true;
protontricks.enable = true; remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server protontricks.enable = true;
localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers 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; [ environment.systemPackages = with pkgs; [
steam-run steam-run
wineWowPackages.stable
wine64
wineWowPackages.waylandFull
]; ];
}) })
(lib.mkIf cfg.steam.enableGamescope {
programs.steam.gamescopeSession.enable = true;
programs.gamescope = {
enable = true;
capSysNice = true;
};
})
]; ];
} }