7 cfg = config.programs.gamescope;
12 optional (cfg.args != [ ])
13 ''--add-flags "${toString cfg.args}"''
14 ++ builtins.attrValues (mapAttrs (var: val: "--set-default ${var} ${val}") cfg.env);
16 pkgs.runCommand "gamescope" { nativeBuildInputs = [ pkgs.makeBinaryWrapper ]; } ''
18 makeWrapper ${cfg.package}/bin/gamescope $out/bin/gamescope --inherit-argv0 \
19 ${toString wrapperArgs}
23 options.programs.gamescope = {
24 enable = mkEnableOption (mdDoc "gamescope");
28 default = pkgs.gamescope;
29 defaultText = literalExpression "pkgs.gamescope";
30 description = mdDoc ''
31 The GameScope package to use.
35 capSysNice = mkOption {
38 description = mdDoc ''
39 Add cap_sys_nice capability to the GameScope
40 binary so that it may renice itself.
45 type = types.listOf types.str;
47 example = [ "--rt" "--prefer-vk-device 8086:9bc4" ];
48 description = mdDoc ''
49 Arguments passed to GameScope on startup.
54 type = types.attrsOf types.str;
56 example = literalExpression ''
57 # for Prime render offload on Nvidia laptops.
58 # Also requires `hardware.nvidia.prime.offload.enable`.
60 __NV_PRIME_RENDER_OFFLOAD = "1";
61 __VK_LAYER_NV_optimus = "NVIDIA_only";
62 __GLX_VENDOR_LIBRARY_NAME = "nvidia";
65 description = mdDoc ''
66 Default environment variables available to the GameScope process, overridable at runtime.
71 config = mkIf cfg.enable {
72 security.wrappers = mkIf cfg.capSysNice {
76 source = "${gamescope}/bin/gamescope";
77 capabilities = "cap_sys_nice+pie";
81 environment.systemPackages = mkIf (!cfg.capSysNice) [ gamescope ];
84 meta.maintainers = with maintainers; [ nrdxp ];