main
 1{
 2  den.aspects.game.steam = {
 3    cacheHome = {config, ...}: {
 4      directories = [
 5        "${config.xdg.configHome}/millennium"
 6        "${config.xdg.dataHome}/millennium"
 7        "${config.xdg.dataHome}/Steam"
 8        ".steam"
 9      ];
10    };
11
12    nixos = {pkgs, ...}: let
13      millennium-src = pkgs.fetchFromGitHub {
14        owner = "SteamClientHomebrew";
15        repo = "Millennium";
16        rev = "v3.3.1";
17        hash = "sha256-nqNRtEkYgXawzpw/xCAgMSyaHKl5GFvzKm8WOoaUN24=";
18      };
19      millennium = pkgs.callPackage "${millennium-src}/packages/nix/millennium.nix" {inherit millennium-src;};
20      millennium-steam = pkgs.callPackage "${millennium-src}/packages/nix/steam.nix" {inherit millennium;};
21    in {
22      hardware = {
23        steam-hardware.enable = true;
24      };
25
26      programs.steam = {
27        enable = true;
28        dedicatedServer.openFirewall = true;
29
30        extraCompatPackages = [
31          pkgs.proton-ge-bin
32          pkgs.nur.repos.vladexa.proton-cachyos-v3
33          pkgs.nur.repos.hpcesia.dwproton-bin
34        ];
35
36        package = millennium-steam.override {
37          extraEnv = {
38            MANGOHUD = true;
39            OBS_VKCAPTURE = true;
40            PROTON_ENABLE_WAYLAND = true;
41            PROTON_ENABLE_HDR = true;
42            PROTON_USE_NTSYNC = true;
43            PROTON_USE_WOW64 = true;
44          };
45        };
46      };
47
48      # https://steamdeck-packages.steamos.cloud/archlinux-mirror/jupiter-main/os/x86_64/steamos-customizations-jupiter-20250117.1-1-any.pkg.tar.zst
49      boot.kernel.sysctl = {
50        # 20-shed.conf
51        "kernel.sched_cfs_bandwidth_slice_us" = 3000;
52        # 20-net-timeout.conf
53        # This is required due to some games being unable to reuse their TCP ports
54        # if they're killed and restarted quickly - the default timeout is too large.
55        "net.ipv4.tcp_fin_timeout" = 5;
56        # 30-splitlock.conf
57        # Prevents intentional slowdowns in case games experience split locks
58        # This is valid for kernels v6.0+
59        "kernel.split_lock_mitigate" = 0;
60        # 30-vm.conf
61        # USE MAX_INT - MAPCOUNT_ELF_CORE_MARGIN.
62        "vm.max_map_count" = 2147483642;
63      };
64    };
65  };
66}