1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-28 03:56:48 +03:00
nixpkgs/nixos/modules/programs/gamescope.nix
Silvan Mosberger 667d42c00d treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
      --argstr baseRev 57b193d8dd
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:27:17 +01:00

82 lines
2.2 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.gamescope;
gamescope =
let
wrapperArgs =
lib.optional (cfg.args != [ ]) ''--add-flags "${builtins.toString cfg.args}"''
++ builtins.attrValues (builtins.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 \
${builtins.toString wrapperArgs}
ln -s ${cfg.package}/bin/gamescopectl $out/bin/gamescopectl
'';
in
{
options.programs.gamescope = {
enable = lib.mkEnableOption "gamescope, the SteamOS session compositing window manager";
package = lib.mkPackageOption pkgs "gamescope" { };
capSysNice = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Add cap_sys_nice capability to the GameScope
binary so that it may renice itself.
'';
};
args = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
example = [
"--rt"
"--prefer-vk-device 8086:9bc4"
];
description = ''
Arguments passed to GameScope on startup.
'';
};
env = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
default = { };
example = lib.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 = lib.mkIf cfg.enable {
security.wrappers = lib.mkIf cfg.capSysNice {
gamescope = {
owner = "root";
group = "root";
source = "${gamescope}/bin/gamescope";
capabilities = "cap_sys_nice+pie";
};
};
environment.systemPackages = lib.mkIf (!cfg.capSysNice) [ gamescope ];
};
meta.maintainers = with lib.maintainers; [ nrdxp ];
}