From ddfcbd78c80707b1f011bbf89a373cc8c0bbd437 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Sun, 22 Dec 2024 22:32:50 -0800 Subject: [PATCH] refactor: modularize gaming module and fold in hamachi --- modules/linux/gaming/default.nix | 108 +++++++++++------- modules/linux/hamachi/default.nix | 4 - .../youwen/linux/packages/x86_64/default.nix | 1 - 3 files changed, 64 insertions(+), 49 deletions(-) delete mode 100644 modules/linux/hamachi/default.nix diff --git a/modules/linux/gaming/default.nix b/modules/linux/gaming/default.nix index 8c0fc02..2e4493c 100755 --- a/modules/linux/gaming/default.nix +++ b/modules/linux/gaming/default.nix @@ -1,55 +1,75 @@ -{ pkgs, ... }: { - environment.systemPackages = with pkgs; [ - ryujinx - mangohud - mangojuice - ]; - programs.steam = { - enable = true; - remotePlay.openFirewall = true; - dedicatedServer.openFirewall = true; - localNetworkGameTransfers.openFirewall = true; - gamescopeSession.enable = true; + pkgs, + lib, + config, + ... +}: +let + cfg = config.liminalOS.extras.gaming; +in +{ + options.liminalOS.extras.gaming = { + enable = lib.mkEnableOption "gaming"; + withHamachi = lib.mkEnableOption "hamachi"; }; + config = lib.mkIf cfg.enable { + environment.systemPackages = with pkgs; [ + ryujinx + lutris + heroic + mangohud + mangojuice + ]; - programs.gamescope.enable = true; + programs.steam = { + enable = true; + remotePlay.openFirewall = true; + dedicatedServer.openFirewall = true; + localNetworkGameTransfers.openFirewall = true; + gamescopeSession.enable = true; + }; - programs.gamemode = { - enable = true; - enableRenice = true; - settings = { - general = { - renice = 10; - }; - custom = { - start = "${pkgs.libnotify}/bin/notify-send 'GameMode engaged'"; - end = "${pkgs.libnotify}/bin/notify-send 'GameMode disengaged'"; + programs.gamescope.enable = true; + + programs.gamemode = { + enable = true; + enableRenice = true; + settings = { + general = { + renice = 10; + }; + custom = { + start = "${pkgs.libnotify}/bin/notify-send 'GameMode engaged'"; + end = "${pkgs.libnotify}/bin/notify-send 'GameMode disengaged'"; + }; }; }; - }; - users.users.youwen.extraGroups = [ "gamemode" ]; + users.users.${config.liminalOS.username}.extraGroups = [ "gamemode" ]; - nixpkgs.config.packageOverrides = pkgs: { - steam = pkgs.steam.override { - extraPkgs = - pkgs: with pkgs; [ - xorg.libXcursor - xorg.libXi - xorg.libXinerama - xorg.libXScrnSaver - libpng - libpulseaudio - libvorbis - stdenv.cc.cc.lib - libkrb5 - (writeShellScriptBin "launch-gamescope" '' - (sleep 1; pgrep gamescope| xargs renice -n -11 -p)& - exec gamescope "$@" - '') - keyutils - ]; + services.logmein-hamachi.enable = cfg.withHamachi; + programs.haguichi.enable = cfg.withHamachi; + + nixpkgs.config.packageOverrides = pkgs: { + steam = pkgs.steam.override { + extraPkgs = + pkgs: with pkgs; [ + xorg.libXcursor + xorg.libXi + xorg.libXinerama + xorg.libXScrnSaver + libpng + libpulseaudio + libvorbis + stdenv.cc.cc.lib + libkrb5 + (writeShellScriptBin "launch-gamescope" '' + (sleep 1; pgrep gamescope| xargs renice -n -11 -p)& + exec gamescope "$@" + '') + keyutils + ]; + }; }; }; } diff --git a/modules/linux/hamachi/default.nix b/modules/linux/hamachi/default.nix deleted file mode 100644 index 80be52a..0000000 --- a/modules/linux/hamachi/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ - services.logmein-hamachi.enable = true; - programs.haguichi.enable = true; -} diff --git a/users/youwen/linux/packages/x86_64/default.nix b/users/youwen/linux/packages/x86_64/default.nix index 415aa94..035e094 100644 --- a/users/youwen/linux/packages/x86_64/default.nix +++ b/users/youwen/linux/packages/x86_64/default.nix @@ -12,7 +12,6 @@ in ++ (with pkgs; [ bitwarden-desktop modrinth-app - lutris sbctl r2modman zoom-us