Skip to content

Commit

Permalink
WIP tech debt
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony Rabbito <[email protected]>
  • Loading branch information
anthr76 committed Jul 19, 2024
1 parent f329a4f commit 631e4dd
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 127 deletions.
72 changes: 36 additions & 36 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion home-manager/personalities/desktop/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
moonlight-qt
syncthing
zoom-us
bottles
system76-keyboard-configurator
podman-desktop
mumble
Expand Down
108 changes: 108 additions & 0 deletions modules/nixos/0001-allow-gamescope-to-set-ctx-priority.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
From f277c47bde65569d8395764e7210aba0b36761a4 Mon Sep 17 00:00:00 2001
From: Anthony Rabbito <[email protected]>
Date: Thu, 18 Jul 2024 22:01:44 -0400
Subject: [PATCH] ctx

Signed-off-by: Anthony Rabbito <[email protected]>
---
src/Utils/Process.cpp | 67 ++-----------------------------------------
1 file changed, 2 insertions(+), 65 deletions(-)

diff --git a/src/Utils/Process.cpp b/src/Utils/Process.cpp
index 32c52f1..13bc0b2 100644
--- a/src/Utils/Process.cpp
+++ b/src/Utils/Process.cpp
@@ -82,7 +82,7 @@ namespace gamescope::Process

char szPath[ PATH_MAX ];
snprintf( szPath, sizeof( szPath ), "/proc/%s/stat", pEntry->d_name );
-
+
FILE *pStatFile = fopen( szPath, "r" );
if ( !pStatFile )
continue;
@@ -408,80 +408,17 @@ namespace gamescope::Process

bool HasCapSysNice()
{
-#if defined(__linux__) && HAVE_LIBCAP
- static bool s_bHasCapSysNice = []() -> bool
- {
- cap_t pCaps = cap_get_proc();
- if ( !pCaps )
- return false;
- defer( cap_free( pCaps ) );
-
- cap_flag_value_t eNiceCapValue = CAP_CLEAR;
- if ( cap_get_flag( pCaps, CAP_SYS_NICE, CAP_EFFECTIVE, &eNiceCapValue ) != 0 )
- return false;
-
- return eNiceCapValue == CAP_SET;
- }();
-
- return s_bHasCapSysNice;
-#else
- return false;
-#endif
+ return true;
}

std::optional<int> g_oOldNice;
std::optional<int> g_oNewNice;
void SetNice( int nNice )
{
-#if defined(__linux__)
- if ( !HasCapSysNice() )
- return;
-
- errno = 0;
- int nOldNice = nice( 0 );
- if ( nOldNice != -1 || errno == 0 )
- {
- g_oOldNice = nOldNice;
- }
-
- errno = 0;
- int nNewNice = nice( -20 );
- if ( nNewNice != -1 || errno == 0 )
- {
- g_oNewNice = nNewNice;
- }
-#endif
}

void RestoreNice()
{
-#if defined(__linux__)
- if ( !HasCapSysNice() )
- return;
-
- if ( !g_oOldNice || !g_oNewNice )
- return;
-
- if ( *g_oOldNice == *g_oNewNice )
- return;
-
- errno = 0;
- int nNewNice = nice( *g_oOldNice - *g_oNewNice );
- if ( g_oNewNice != -1 || errno == 0 )
- {
- g_oNewNice = nNewNice;
- }
-
- if ( g_oOldNice == g_oNewNice )
- {
- g_oOldNice = std::nullopt;
- g_oNewNice = std::nullopt;
- }
- else
- {
- s_ProcessLog.errorf( "RestoreNice: Old Nice != New Nice" );
- }
-#endif
}

struct SchedulerInfo
--
2.45.1

14 changes: 12 additions & 2 deletions modules/nixos/gaming-kernel.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# TODO: Make this much more robust if it proves useful.
{ pkgs, inputs, lib, config, ... }: {
{ pkgs, lib, config, ... }: {

# imports = [ inputs.chaotic.nixosModules.default ];
options = {
gaming-kernel = {
enable = lib.mkEnableOption
Expand All @@ -21,5 +20,16 @@
}
];
boot.kernelPackages = lib.mkForce pkgs.linuxPackages_cachyos;
nixpkgs = {
overlays = [
(final: prev: {
gamescope = prev.gamescope.overrideAttrs (oldAttrs: {
patches = oldAttrs.patches ++ [
./0001-allow-gamescope-to-set-ctx-priority.patch
];
});
})
];
};
};
}
File renamed without changes.
11 changes: 11 additions & 0 deletions nixos/personalities/desktop/gaming.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{ inputs, pkgs, lib, ... }: {
# chaotic.mesa-git.enable = true;
# nixpkgs = {
# overlays = [
# (final: prev: {
# gamescope = prev.gamescope.overrideAttrs (oldAttrs: {
# patches = oldAttrs.patches ++ [
# ./gamescope-overlay.patch
# ];
# });
# })
# ];
# };
programs.steam = {
enable = true;
gamescopeSession.enable = true;
Expand Down
34 changes: 0 additions & 34 deletions overlays/0001-allow-gamescope-to-set-ctx-priority.patch

This file was deleted.

2 changes: 0 additions & 2 deletions overlays/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@
gamescope = prev.gamescope.overrideAttrs (oldAttrs: {
patches = oldAttrs.patches ++ [
./gamescope-native-res.patch
./0001-allow-gamescope-to-set-ctx-priority.patch
./gamescope-overlay.patch
];
});
logiops = prev.logiops.overrideAttrs (oldAttrs: {
Expand Down
Loading

0 comments on commit 631e4dd

Please sign in to comment.