Files
chiasson-nix/modules/system/gaming.nix
T
2026-05-08 19:12:16 -03:00

129 lines
4.3 KiB
Nix

{ ... }: {
flake.nixosModules.systemGaming =
{ config, lib, pkgs, ... }:
let
cfg = config.chiasson.system.gaming;
launcherPkgs =
with pkgs;
[
lutris
bottles
wine
winetricks
gamemode
mangohud
goverlay
]
++ lib.optionals pkgs.stdenv.isx86_64 [ heroic ];
steamExtraPkgs =
if !cfg.steam.steamTinkerLaunch.enable then
[ ]
else
lib.optional (lib.meta.availableOn pkgs.stdenv.hostPlatform pkgs.steamtinkerlaunch) pkgs.steamtinkerlaunch;
in
{
options.chiasson.system.gaming = {
enable = lib.mkEnableOption ''
Steam (+ firewall toggles), 32-bit GL/Vulkan, gamemode, JACK via PipeWire, launcher bundle.
'';
steam = {
remotePlay.openFirewall = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Open firewall for Steam Remote Play.";
};
dedicatedServer.openFirewall = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Open firewall for Steam dedicated servers.";
};
steamTinkerLaunch.enable = lib.mkEnableOption ''
[SteamTinkerLaunch](https://github.com/frostworx/steamtinkerlaunch) Steam wrapper for
custom launch options, Proton helpers, and third-party tools. Adds `pkgs.steamtinkerlaunch`
next to the launcher package set (`environment.systemPackages` or `launchers.forUsers`).
'';
};
graphics = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "`hardware.graphics.enable` (Vulkan/GL stack).";
};
enable32Bit = lib.mkOption {
type = lib.types.bool;
default = true;
description = "`hardware.graphics.enable32Bit` (Steam / Proton 32-bit).";
};
};
gamemode.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "`programs.gamemode` (Feral GameMode).";
};
jack.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Set `chiasson.system.audio.pipewire.jack.enable` (PipeWire JACK). Requires
`chiasson.system.audio.enable` on the host.
'';
};
launchers = {
forUsers = lib.mkOption {
type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null;
description = ''
Per-user `packages` for launchers; `null` `environment.systemPackages`.
'';
};
extraPackages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ ];
description = "Additional packages merged with the default launcher set.";
};
};
};
config = lib.mkIf cfg.enable (lib.mkMerge [
{
programs.steam = {
enable = true;
remotePlay.openFirewall = cfg.steam.remotePlay.openFirewall;
dedicatedServer.openFirewall = cfg.steam.dedicatedServer.openFirewall;
};
hardware.graphics = lib.mkIf cfg.graphics.enable {
enable = true;
enable32Bit = cfg.graphics.enable32Bit;
};
programs.gamemode.enable = cfg.gamemode.enable;
chiasson.system.audio.pipewire.jack.enable = lib.mkIf (cfg.jack.enable) (lib.mkDefault true);
assertions = [
{
assertion = !cfg.enable || !cfg.jack.enable || config.chiasson.system.audio.enable;
message = "chiasson.system.gaming with JACK requires `chiasson.system.audio.enable` (PipeWire).";
}
];
}
(lib.mkIf (cfg.launchers.forUsers == null) {
environment.systemPackages = launcherPkgs ++ steamExtraPkgs ++ cfg.launchers.extraPackages;
})
(lib.mkIf (cfg.launchers.forUsers != null) {
users.users = lib.genAttrs cfg.launchers.forUsers (_: {
packages = launcherPkgs ++ steamExtraPkgs ++ cfg.launchers.extraPackages;
});
})
]);
};
}