main
 1{
 2  den.aspects.desktop.game.steam = {
 3    cacheHome = {config, ...}: {
 4      directories = [
 5        "${config.xdg.config.directory}/millennium"
 6        "${config.xdg.data.directory}/millennium"
 7        "${config.xdg.data.directory}/Steam"
 8        ".steam"
 9      ];
10    };
11
12    nixos = {pkgs, ...}: let
13      millennium-src = pkgs.fetchFromGitHub {
14        owner = "SteamClientHomebrew";
15        repo = "Millennium";
16        tag = "v3.5.0";
17        hash = "sha256-ghYUa4gPLV/VOflM2zkl/gtdwLWHQpRxG4boQoj4yKM=";
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      # dwproton-11.0-13 broke DualSense haptics/controller-speaker
22      # pin 11.0-12 until fixed upstream.
23      dwproton-bin = pkgs.dwproton-bin.overrideAttrs (_: {
24        version = "dwproton-11.0-12";
25        toolName = "dwproton-11.0-12-x86_64";
26        src = pkgs.fetchzip {
27          url = "https://dawn.wine/dawn-winery/dwproton/releases/download/dwproton-11.0-12/dwproton-11.0-12-x86_64.tar.xz";
28          hash = "sha256-NGyrXQcA+k87SnowFd41uq49luI32fZENTwFTma7NpI=";
29        };
30      });
31    in {
32      hardware = {
33        steam-hardware.enable = true;
34      };
35
36      programs.steam = {
37        enable = true;
38        dedicatedServer.openFirewall = true;
39
40        extraCompatPackages = [
41          pkgs.proton-ge-bin
42          dwproton-bin
43          pkgs.nur.repos.vladexa.proton-cachyos-v3
44        ];
45
46        package = millennium-steam.override {
47          extraEnv = {
48            MANGOHUD = true;
49            OBS_VKCAPTURE = true;
50            PROTON_ENABLE_WAYLAND = true;
51            PROTON_ENABLE_HDR = true;
52            PROTON_USE_NTSYNC = true;
53            PROTON_USE_WOW64 = true;
54          };
55        };
56      };
57
58      # https://steamdeck-packages.steamos.cloud/archlinux-mirror/jupiter-main/os/x86_64/steamos-customizations-jupiter-20250117.1-1-any.pkg.tar.zst
59      boot.kernel.sysctl = {
60        # 20-shed.conf
61        "kernel.sched_cfs_bandwidth_slice_us" = 3000;
62        # 20-net-timeout.conf
63        # This is required due to some games being unable to reuse their TCP ports
64        # if they're killed and restarted quickly - the default timeout is too large.
65        "net.ipv4.tcp_fin_timeout" = 5;
66        # 30-splitlock.conf
67        # Prevents intentional slowdowns in case games experience split locks
68        # This is valid for kernels v6.0+
69        "kernel.split_lock_mitigate" = 0;
70        # 30-vm.conf
71        # USE MAX_INT - MAPCOUNT_ELF_CORE_MARGIN.
72        "vm.max_map_count" = 2147483642;
73      };
74    };
75  };
76}