summary refs log tree commit diff stats
path: root/system/settings/gaming.nix
blob: 3a0c134e915faee41f1e7bbd30d3317690319323 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
{
  config,
  pkgs,
  ...
}: {
  programs.steam.enable = true;
  programs.gamemode = {
    enable = true;
    settings = {
      general = {
        renice = 5;
      };

      custom = {
        start = "${pkgs.libnotify}/bin/notify-send 'GameMode started'";
        end = "${pkgs.libnotify}/bin/notify-send 'GameMode ended'";
      };
    };
  };
  fonts.fontconfig.cache32Bit = true;
  hardware.steam-hardware.enable = true;
  hardware.opengl.driSupport32Bit = true;
  hardware.pulseaudio.support32Bit = true;
  services.pipewire.alsa.support32Bit = true;
  services.pipewire.config.pipewire = {
    "context.properties" = {
      "link.max-buffers" = 16;
      "log.level" = 2;
      "default.clock.rate" = 44100;
      "default.clock.allowed_rates" = [44100 48000 88200 96000];
      "default.clock.quantum" = 32;
      "default.clock.min-quantum" = 32;
      "default.clock.max-quantum" = 32;
      "core.daemon" = true;
      "core.name" = "pipewire-0";
    };
    "context.modules" = [
      {
        name = "libpipewire-module-rtkit";
        args = {
          "nice.level" = -15;
          "rt.prio" = 88;
          "rt.time.soft" = 200000;
          "rt.time.hard" = 200000;
        };
        flags = ["ifexists" "nofail"];
      }
      {name = "libpipewire-module-protocol-native";}
      {name = "libpipewire-module-profiler";}
      {name = "libpipewire-module-metadata";}
      {name = "libpipewire-module-spa-device-factory";}
      {name = "libpipewire-module-spa-node-factory";}
      {name = "libpipewire-module-client-node";}
      {name = "libpipewire-module-client-device";}
      {
        name = "libpipewire-module-portal";
        flags = ["ifexists" "nofail"];
      }
      {
        name = "libpipewire-module-access";
        args = {};
      }
      {name = "libpipewire-module-adapter";}
      {name = "libpipewire-module-link-factory";}
      {name = "libpipewire-module-session-manager";}
    ];
    "stream.properties" = {
      "node.latency" = "32/44100";
      "resample.quality" = 1;
    };
  };
  services.pipewire.config.pipewire-pulse = {
    "context.properties" = {
      "log.level" = 2;
    };
    "pulse.properties" = {
      "server.address" = [
        "unix:native"
        "tcp:127.0.0.1:4713"
      ];
    };
    "context.modules" = [
      {
        name = "libpipewire-module-rtkit";
        args = {
          "nice.level" = -15;
          "rt.prio" = 88;
          "rt.time.soft" = 200000;
          "rt.time.hard" = 200000;
        };
        flags = ["ifexists" "nofail"];
      }
      {name = "libpipewire-module-protocol-native";}
      {name = "libpipewire-module-client-node";}
      {name = "libpipewire-module-adapter";}
      {name = "libpipewire-module-metadata";}
      {
        name = "libpipewire-module-protocol-pulse";
        args = {
          "pulse.min.req" = "32/48000";
          "pulse.default.req" = "32/48000";
          "pulse.max.req" = "32/48000";
          "pulse.min.quantum" = "32/48000";
          "pulse.max.quantum" = "32/48000";
          "server.address" = [
            "unix:native"
            "tcp:127.0.0.1:4713"
          ];
        };
      }
    ];
    "stream.properties" = {
      "node.latency" = "32/48000";
      "resample.quality" = 1;
    };
  };

  systemd = {
    extraConfig = ''
      DefaultLimitNOFILE=524288
    '';
    user.extraConfig = ''
      DefaultLimitNOFILE=524288
    '';
  };

  services.ananicy = {
    enable = true;
    package = pkgs.ananicy-cpp;
  };

  networking.firewall = {
    allowedUDPPorts = [
      27031
      27036
    ];
    allowedTCPPorts = [
      27036
      27037
    ];
  };
}