Skip to content

Commit

Permalink
fixing repeated code with a module for gaming utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Octelly committed Dec 27, 2024
1 parent 4fe1845 commit a667a28
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 33 deletions.
29 changes: 29 additions & 0 deletions hosts/ocean-desktop/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
switch = true;
wii = true;
};
utils.overlays.vkbasalt = true;
};
awesome = {
enable = true;
Expand All @@ -36,6 +37,24 @@
'';
};

programs.alvr = {
enable = true;
openFirewall = true;
};

# required for NixOS SteamVR to work
# https://wiki.nixos.org/wiki/VR/en#SteamVR
boot.kernelPatches = [
{
name = "amdgpu-ignore-ctx-privileges";
patch = pkgs.fetchpatch {
name = "cap_sys_nice_begone.patch";
url = "https://github.com/Frogging-Family/community-patches/raw/master/linux61-tkg/cap_sys_nice_begone.mypatch";
hash = "sha256-Y3a0+x2xvHsfLax/uwycdJf3xLxvVfkfDVqjkxNaYEo=";
};
}
];

#services.davfs2 = {
# enable = true;
# settings.sections = {
Expand All @@ -60,6 +79,16 @@
# #"async" # ??
# ];
#};

fileSystems."/tmp" = {
device = "none";
fsType = "tmpfs";
options = [
"defaults"
"size=150%"
];
};

networking.firewall.allowedTCPPorts = [
3216 # EA App
];
Expand Down
16 changes: 4 additions & 12 deletions modules/desktop/gaming/emulation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ with lib;
let cfg = config.modules.desktop.gaming.emulation;
in {
options.modules.desktop.gaming.emulation = {
enable = mkEnableOption "enable the emulation module";
enable = mkEnableOption "the emulation module";
switch = mkEnableOption "Nintendo Switch";
gamecube = mkEnableOption "Nintendo GameCube";
wii = mkEnableOption "Nintendo Wii";
Expand All @@ -15,18 +15,10 @@ in {

config = mkIf cfg.enable {

programs.gamemode = {
enable = true;
enableRenice = true;
};
# some emulators support gamemode natively
modules.desktop.gaming.utils.gamemode = mkDefault true;

environment.systemPackages = with pkgs; [
# helpful overlays and such
mangohud
vkbasalt
# a configurator for them
goverlay
]
environment.systemPackages = []
++ optional cfg.switch pkgs.ryujinx
++ optional (cfg.gamecube || cfg.wii) pkgs.dolphin-emu
++ optional cfg.primehack pkgs.dolphin-emu-primehack;
Expand Down
35 changes: 14 additions & 21 deletions modules/desktop/gaming/steam.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,26 @@ in {
programs.steam = {
enable = true;

remotePlay.openFirewall = true;
localNetworkGameTransfers.openFirewall = true;
remotePlay.openFirewall = mkDefault true;
localNetworkGameTransfers.openFirewall = mkDefault true;

# wayland thing
# makes Steam Input and such behave better under Wayland
extest.enable = true;

protontricks.enable = true;
gamescopeSession.enable = true;
protontricks.enable = mkDefault true;
gamescopeSession.enable = mkDefault true;
};

programs.gamemode = {
enable = true;
enableRenice = true;
};

environment = {
sessionVariables.STEAM_EXTRA_COMPAT_TOOLS_PATHS = "\${HOME}/.steam/root/compatibilitytools.d";
modules.desktop.gaming.utils = {
protonup = mkDefault true;

systemPackages = with pkgs; [
protonup-qt

# helpful overlays and such
mangohud
vkbasalt
# a configurator for them
goverlay
];
# both gamemode and mangohud will have to be enabled manually per game
gamemode = mkDefault true;
overlays.mangohud = mkDefault true;
};

environment
.sessionVariables
.STEAM_EXTRA_COMPAT_TOOLS_PATHS = "\${HOME}/.steam/root/compatibilitytools.d";
};
}
46 changes: 46 additions & 0 deletions modules/desktop/gaming/utils..nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

{ config, pkgs, lib, inputs, system, ... }:

with builtins;
with lib;
let
cfg = config.modules.desktop.gaming.utils;
# mkEnableOption, but you can set the default
mkEnableDefault = name: default: mkOption {
inherit default;
example = true;
description = "Whether to enable ${name}.";
type = types.bool;
};
# or operation for a list - if a single value is true, return true
anyTrue = list: lists.any (x: x) list;
isSteamEnabled = config.modules.desktop.gaming.steam.enable;
in {
options.modules.desktop.gaming.utils = {
overlayConfigGUI = mkEnableDefault
"goverlay - a configurator for game overlays"
(anyTrue (attrsets.attrValues cfg.overlays));

overlays = {
mangohud = mkEnableOption "MangoHUD - FPS counter";
vkbasalt = mkEnableOption "vkbasalt - shaders";
};

protonup = mkEnableOption "protonup-qt - GUI manager for compatibility tools";

gamemode = mkEnableOption "gamemode for extra performance during games";
};

config = {
programs.gamemode = mkIf cfg.gamemode {
enable = true;
enableRenice = mkDefault true;
};

environment.systemPackages = []
++ optional cfg.overlayConfigGUI pkgs.goverlay
++ optional cfg.overlays.mangohud pkgs.mangohud
++ optional cfg.overlays.vkbasalt pkgs.vkbasalt
++ optional cfg.protonup pkgs.protonup-qt;
};
}

0 comments on commit a667a28

Please sign in to comment.