tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
nixos/gamemode: add module
Kira Bruneau
4 years ago
caac437b
1c7d2e04
+97
-1
3 changed files
expand all
collapse all
unified
split
nixos
modules
module-list.nix
programs
gamemode.nix
pkgs
tools
games
gamemode
default.nix
+1
nixos/modules/module-list.nix
···
139
139
./programs/flexoptix-app.nix
140
140
./programs/freetds.nix
141
141
./programs/fuse.nix
142
142
+
./programs/gamemode.nix
142
143
./programs/geary.nix
143
144
./programs/gnome-disks.nix
144
145
./programs/gnome-documents.nix
+96
nixos/modules/programs/gamemode.nix
···
1
1
+
{ config, lib, pkgs, ... }:
2
2
+
3
3
+
with lib;
4
4
+
5
5
+
let
6
6
+
cfg = config.programs.gamemode;
7
7
+
settingsFormat = pkgs.formats.ini { };
8
8
+
configFile = settingsFormat.generate "gamemode.ini" cfg.settings;
9
9
+
in
10
10
+
{
11
11
+
options = {
12
12
+
programs.gamemode = {
13
13
+
enable = mkEnableOption "GameMode to optimise system performance on demand";
14
14
+
15
15
+
enableRenice = mkEnableOption "CAP_SYS_NICE on gamemoded to support lowering process niceness" // {
16
16
+
default = true;
17
17
+
};
18
18
+
19
19
+
settings = mkOption {
20
20
+
type = settingsFormat.type;
21
21
+
default = {};
22
22
+
description = ''
23
23
+
System-wide configuration for GameMode (/etc/gamemode.ini).
24
24
+
See gamemoded(8) man page for available settings.
25
25
+
'';
26
26
+
example = literalExample ''
27
27
+
{
28
28
+
general = {
29
29
+
renice = 10;
30
30
+
};
31
31
+
32
32
+
# Warning: GPU optimisations have the potential to damage hardware
33
33
+
gpu = {
34
34
+
apply_gpu_optimisations = "accept-responsibility";
35
35
+
gpu_device = 0;
36
36
+
amd_performance_level = "high";
37
37
+
};
38
38
+
39
39
+
custom = {
40
40
+
start = "''${pkgs.libnotify}/bin/notify-send 'GameMode started'";
41
41
+
end = "''${pkgs.libnotify}/bin/notify-send 'GameMode ended'";
42
42
+
};
43
43
+
}
44
44
+
'';
45
45
+
};
46
46
+
};
47
47
+
};
48
48
+
49
49
+
config = mkIf cfg.enable {
50
50
+
environment = {
51
51
+
systemPackages = [ pkgs.gamemode ];
52
52
+
etc."gamemode.ini".source = configFile;
53
53
+
};
54
54
+
55
55
+
security = {
56
56
+
polkit.enable = true;
57
57
+
wrappers = mkIf cfg.enableRenice {
58
58
+
gamemoded = {
59
59
+
source = "${pkgs.gamemode}/bin/gamemoded";
60
60
+
capabilities = "cap_sys_nice+ep";
61
61
+
};
62
62
+
};
63
63
+
};
64
64
+
65
65
+
systemd = {
66
66
+
packages = [ pkgs.gamemode ];
67
67
+
user.services.gamemoded = {
68
68
+
# The upstream service already defines this, but doesn't get applied.
69
69
+
# See https://github.com/NixOS/nixpkgs/issues/81138
70
70
+
wantedBy = [ "default.target" ];
71
71
+
72
72
+
# Use pkexec from the security wrappers to allow users to
73
73
+
# run libexec/cpugovctl & libexec/gpuclockctl as root with
74
74
+
# the the actions defined in share/polkit-1/actions.
75
75
+
#
76
76
+
# This uses a link farm to make sure other wrapped executables
77
77
+
# aren't included in PATH.
78
78
+
environment.PATH = mkForce (pkgs.linkFarm "pkexec" [
79
79
+
{
80
80
+
name = "pkexec";
81
81
+
path = "${config.security.wrapperDir}/pkexec";
82
82
+
}
83
83
+
]);
84
84
+
85
85
+
serviceConfig.ExecStart = mkIf cfg.enableRenice [
86
86
+
"" # Tell systemd to clear the existing ExecStart list, to prevent appending to it.
87
87
+
"${config.security.wrapperDir}/gamemoded"
88
88
+
];
89
89
+
};
90
90
+
};
91
91
+
};
92
92
+
93
93
+
meta = {
94
94
+
maintainers = with maintainers; [ kira-bruneau ];
95
95
+
};
96
96
+
}
-1
pkgs/tools/games/gamemode/default.nix
···
20
20
owner = "FeralInteractive";
21
21
repo = pname;
22
22
rev = version;
23
23
-
fetchSubmodules = true;
24
23
sha256 = "sha256-P00OnZiPZyxBu9zuG+3JNorXHBhJZy+cKPjX+duZrJ0=";
25
24
};
26
25