nixos(steam): add gamescope session option
This commit is contained in:
@@ -36,7 +36,8 @@ in
|
|||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = mdDoc ''
|
description = mdDoc ''
|
||||||
Add cap_sys_nice capability to the GameScope binary.
|
Add cap_sys_nice capability to the GameScope
|
||||||
|
binary so that it may renice itself.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,24 @@ with lib;
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.programs.steam;
|
cfg = config.programs.steam;
|
||||||
|
gamescopeCfg = config.programs.gamescope;
|
||||||
|
|
||||||
|
steam-gamescope = let
|
||||||
|
exports = builtins.attrValues (builtins.mapAttrs (n: v: "export ${n}=${v}") cfg.gamescopeSession.env);
|
||||||
|
in
|
||||||
|
pkgs.writeShellScriptBin "steam-gamescope" ''
|
||||||
|
${builtins.concatStringsSep "\n" exports}
|
||||||
|
gamescope --steam ${toString cfg.gamescopeSession.args} -- steam -tenfoot -pipewire-dmabuf
|
||||||
|
'';
|
||||||
|
|
||||||
|
gamescopeSessionFile =
|
||||||
|
(pkgs.writeTextDir "share/wayland-sessions/steam.desktop" ''
|
||||||
|
[Desktop Entry]
|
||||||
|
Name=Steam
|
||||||
|
Comment=A digital distribution platform
|
||||||
|
Exec=${steam-gamescope}/bin/steam-gamescope
|
||||||
|
Type=Application
|
||||||
|
'').overrideAttrs (_: { passthru.providedSessions = [ "steam" ]; });
|
||||||
in {
|
in {
|
||||||
options.programs.steam = {
|
options.programs.steam = {
|
||||||
enable = mkEnableOption (lib.mdDoc "steam");
|
enable = mkEnableOption (lib.mdDoc "steam");
|
||||||
@@ -32,6 +50,12 @@ in {
|
|||||||
then [ package ] ++ extraPackages
|
then [ package ] ++ extraPackages
|
||||||
else [ package32 ] ++ extraPackages32;
|
else [ package32 ] ++ extraPackages32;
|
||||||
in prevLibs ++ additionalLibs;
|
in prevLibs ++ additionalLibs;
|
||||||
|
} // optionalAttrs (cfg.gamescopeSession.enable && gamescopeCfg.capSysNice)
|
||||||
|
{
|
||||||
|
buildFHSEnv = pkgs.buildFHSEnv.override {
|
||||||
|
# use the setuid wrapped bubblewrap
|
||||||
|
bubblewrap = "${config.security.wrapperDir}/..";
|
||||||
|
};
|
||||||
});
|
});
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
The Steam package to use. Additional libraries are added from the system
|
The Steam package to use. Additional libraries are added from the system
|
||||||
@@ -57,6 +81,30 @@ in {
|
|||||||
Open ports in the firewall for Source Dedicated Server.
|
Open ports in the firewall for Source Dedicated Server.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
gamescopeSession = mkOption {
|
||||||
|
description = mdDoc "Run a GameScope driven Steam session from your display-manager";
|
||||||
|
type = types.submodule {
|
||||||
|
options = {
|
||||||
|
enable = mkEnableOption (mdDoc "GameScope Session");
|
||||||
|
args = mkOption {
|
||||||
|
type = types.listOf types.string;
|
||||||
|
default = [ ];
|
||||||
|
description = mdDoc ''
|
||||||
|
Arguments to be passed to GameScope for the session.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
env = mkOption {
|
||||||
|
type = types.attrsOf types.string;
|
||||||
|
default = { };
|
||||||
|
description = mdDoc ''
|
||||||
|
Environmental variables to be passed to GameScope for the session.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
@@ -66,6 +114,19 @@ in {
|
|||||||
driSupport32Bit = true;
|
driSupport32Bit = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
security.wrappers = mkIf (cfg.gamescopeSession.enable && gamescopeCfg.capSysNice) {
|
||||||
|
# needed or steam fails
|
||||||
|
bwrap = {
|
||||||
|
owner = "root";
|
||||||
|
group = "root";
|
||||||
|
source = "${pkgs.bubblewrap}/bin/bwrap";
|
||||||
|
setuid = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.gamescope.enable = mkDefault cfg.gamescopeSession.enable;
|
||||||
|
services.xserver.displayManager.sessionPackages = mkIf cfg.gamescopeSession.enable [ gamescopeSessionFile ];
|
||||||
|
|
||||||
# optionally enable 32bit pulseaudio support if pulseaudio is enabled
|
# optionally enable 32bit pulseaudio support if pulseaudio is enabled
|
||||||
hardware.pulseaudio.support32Bit = config.hardware.pulseaudio.enable;
|
hardware.pulseaudio.support32Bit = config.hardware.pulseaudio.enable;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user