nixpkgs/nixos/modules/programs/gamescope.nix
stuebinm 6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00

79 lines
2.0 KiB
Nix

{ config
, lib
, pkgs
, ...
}:
with lib; let
cfg = config.programs.gamescope;
gamescope =
let
wrapperArgs =
optional (cfg.args != [ ])
''--add-flags "${toString cfg.args}"''
++ builtins.attrValues (mapAttrs (var: val: "--set-default ${var} ${val}") cfg.env);
in
pkgs.runCommand "gamescope" { nativeBuildInputs = [ pkgs.makeBinaryWrapper ]; } ''
mkdir -p $out/bin
makeWrapper ${cfg.package}/bin/gamescope $out/bin/gamescope --inherit-argv0 \
${toString wrapperArgs}
'';
in
{
options.programs.gamescope = {
enable = mkEnableOption "gamescope, the SteamOS session compositing window manager";
package = mkPackageOption pkgs "gamescope" { };
capSysNice = mkOption {
type = types.bool;
default = false;
description = ''
Add cap_sys_nice capability to the GameScope
binary so that it may renice itself.
'';
};
args = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ "--rt" "--prefer-vk-device 8086:9bc4" ];
description = ''
Arguments passed to GameScope on startup.
'';
};
env = mkOption {
type = types.attrsOf types.str;
default = { };
example = literalExpression ''
# for Prime render offload on Nvidia laptops.
# Also requires `hardware.nvidia.prime.offload.enable`.
{
__NV_PRIME_RENDER_OFFLOAD = "1";
__VK_LAYER_NV_optimus = "NVIDIA_only";
__GLX_VENDOR_LIBRARY_NAME = "nvidia";
}
'';
description = ''
Default environment variables available to the GameScope process, overridable at runtime.
'';
};
};
config = mkIf cfg.enable {
security.wrappers = mkIf cfg.capSysNice {
gamescope = {
owner = "root";
group = "root";
source = "${gamescope}/bin/gamescope";
capabilities = "cap_sys_nice+pie";
};
};
environment.systemPackages = mkIf (!cfg.capSysNice) [ gamescope ];
};
meta.maintainers = with maintainers; [ nrdxp ];
}