From b284c90451443c8da21739650538240a639e9d3e Mon Sep 17 00:00:00 2001 From: magic_rb Date: Sat, 25 Nov 2023 17:59:48 +0100 Subject: [PATCH] Finally get gamescope working properly in Steam Signed-off-by: magic_rb --- nixos/common/steam.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/nixos/common/steam.nix b/nixos/common/steam.nix index f3dd670..e01ae7e 100644 --- a/nixos/common/steam.nix +++ b/nixos/common/steam.nix @@ -1,9 +1,18 @@ -{ pkgs, lib, ... }: +{ pkgs, lib, config, ... }: { programs.gamemode.enable = true; programs.gamescope = { enable = true; - capSysNice = true; + # Wrappers don't work in steams FHSEnv cause security reasons (ig valid) + capSysNice = false; + }; + + # Therefore we wrap gamescope with the capability under an alias + security.wrappers.gamescope-nice = { + owner = "root"; + group = "root"; + source = "${pkgs.gamescope}/bin/gamescope"; + capabilities = "cap_sys_nice+pie"; }; environment.systemPackages = with pkgs; [ @@ -18,6 +27,8 @@ p.libkrb5 p.keyutils ]; + # this is the worst thing I have written in ages, but it works + buildFHSEnv = x: pkgs.buildFHSEnv (x // { extraBwrapArgs = x.extraBwrapArgs ++ [ "--cap-add CAP_SYS_NICE --cap-add CAP_SETPCAP" ]; }); }; };