summary refs log tree commit diff
path: root/machines/wolfram/devices.nix
blob: 3866465db006cadff4be9b6fb4051832f8a768c7 (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
{ config, pkgs, unstablePkgs, ... }:

{
  # boot settings
  boot = {
    kernelPackages = pkgs.linuxPackages_latest;

    kernelParams = [
      # checking for cache splitting destroys performance on some
      # windows games running via wine/proton, disable it and
      # tank their performance impact, which is lower than checking
      # and handling the splits.
      "split_lock_detect=off"
    ];

    # do not use default kernel module (r8169) for the realtek rtl8125 ethernet
    # controller, as it has issues with packet loss and can't keep up with the high
    # 2.5g link speed.
    # the out-of-tree module r8125 also has issues however, as apparently when sending
    # off packets the hardware offloading done on the network chip fails massively,
    # corrupting a huge amount of packets, breaking off connections and distorting video.
    # the fix to disable the hardware offloading is handled by systemd-networkd below.
    blacklistedKernelModules = [ "r8169" ];
    extraModulePackages = [ config.boot.kernelPackages.r8125 ];
    kernelModules = [ "r8125" ];

    loader = {
      systemd-boot.enable = true;
      efi.canTouchEfiVariables = true;
    };

    initrd.systemd.enable = true;
  };

  # hardware settings
  hardware = {
    enableRedistributableFirmware = true;
    enableAllFirmware = true;

    graphics = {
      enable = true;
      enable32Bit = true;

      # use the most up-to-date mesa we can get from nixos,
      # as the intel arc b570 drivers are still in rapid development,
      # and any changes could improve stability and performance drastically.
      package = unstablePkgs.mesa;
      package32 = unstablePkgs.pkgsi686Linux.mesa;

      extraPackages = with unstablePkgs; [
        vpl-gpu-rt
        intel-media-driver
        intel-compute-runtime
        intel-ocl
      ];
    };

    bluetooth = {
      enable = true;
      powerOnBoot = true;
    };
  };

  # swap alternative
  zramSwap = {
    enable = true;
    algorithm = "zstd";
    swapDevices = 1;
    memoryPercent = 50;
  };

  networking = {
    useDHCP = false;
    dhcpcd.enable = false;
  };
  systemd.network = {
    enable = true;
    networks = {
      # ethernet through the rtl8125 ethernet controller (supports 2.5g)
      "10-ether" = {
        name = "enp7s0";
        DHCP = "yes";

        # higher priority if available
        dhcpV4Config.RouteMetric = 10;
        dhcpV6Config.RouteMetric = 10;
      };
    };

    # the rtl8125 notoriously has extreme issues with offloaded calculations
    # sent from linux machines, and corrupts packets badly, crippling connectivity.
    # we disable most forms of offloading to the chip here, instead handling them
    # in our own kernel. this fixes most of the issues.
    links."10-rtl8125-hardware-offloading" = {
      matchConfig.Driver = "r8125"; # match by driver to prevent udev renaming issues
      linkConfig = {
        # keep naming behavior consistent with defaults
        NamePolicy = "keep kernel database onboard slot path";
        MACAddressPolicy = "persistent";

        # kill hardware offloading for this chipset
        ReceiveChecksumOffload = false; # rx off
        TransmitChecksumOffload = false; # tx off
        TCPSegmentationOffload = false; # tso off
        TCP6SegmentationOffload = false; # tso off (ipv6)
        GenericSegmentationOffload = false; # gso off
        GenericReceiveOffload = false; # gro off
      };
    };
  };

  # sound
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa = {
      enable = true;
      support32Bit = true;
    };
    pulse.enable = true;
    jack.enable = true;
  };

  # other tweaks
  environment.variables = {
    # wine+proton reads this variable to decide which cpus to run a given
    # application on.
    # we choose our p-cores (and the hyperthreads) of the intel i5-14400f
    # and let the e-cores handle all the other system tasks.
    WINE_CPU_TOPOLOGY = "12:0,1,2,3,4,5,6,7,8,9,10,11";
  };
}