feat(nixosmodules): add steam module

This commit is contained in:
Mohammad Rafiq 2025-04-27 20:57:17 +08:00
parent 45f314f71b
commit b62ca97ccb
No known key found for this signature in database
3 changed files with 45 additions and 0 deletions

View file

@ -8,4 +8,6 @@
boot-config.bootloader = "systemd-boot"; boot-config.bootloader = "systemd-boot";
hardware-config.cpu = "amd"; hardware-config.cpu = "amd";
hardware-config.gpu = "nvidia"; hardware-config.gpu = "nvidia";
gaming.steam.enable = true;
gaming.steam.enableGamescope = true;
} }

View file

@ -12,6 +12,7 @@ in
./boot.nix ./boot.nix
./hardware.nix ./hardware.nix
./nix-config.nix ./nix-config.nix
./gaming.nix
]; ];
options = { options = {

42
modules/nixos/gaming.nix Normal file
View file

@ -0,0 +1,42 @@
{
config,
lib,
pkgs,
...
}:
let
moduleName = "gaming";
cfg = config."${moduleName}";
in
{
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
};
environment.systemPackages = with pkgs; [
steam-run
];
})
(lib.mkIf cfg.steam.enableGamescope {
programs.steam.gamescopeSession.enable = true;
programs.gamescope = {
enable = true;
capSysNice = true;
};
})
];
}