summary refs log tree commit diff stats
path: root/system/settings/hardware/bare-metal.nix
blob: db6688304f616b665325bf1f8223d4e5ebc2a203 (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
{ config, pkgs, ... }:

{ environment.systemPackages = with pkgs; [
    fuse_exfat
    cryptsetup
    dmidecode
    hdparm
    pciutils
    usbutils
  ];

  services.udev.extraRules = ''
    # set scheduler for NVMe
    ACTION=="add|change", KERNEL=="nvme[0-9]n[0-9]", ATTR{queue/scheduler}="none"
    # set scheduler for SSD and eMMC
    ACTION=="add|change", KERNEL=="sd[a-z]|mmcblk[0-9]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="mq-deadline"
    # set scheduler for rotating disks
    ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="bfq"
  '';

  boot.kernelModules = [ "tcp_bbr" ];
  boot.kernel.sysctl = {
    "net.core.default_qdisc" = "cake";
    "net.ipv4.tcp_allowed_congestion_control" = "bbr illinois reno lp";
    "net.ipv4.tcp_congestion_control" = "bbr";
    "net.ipv4.tcp_fastopen" = 3;
    "net.ipv4.tcp_slow_start_after_idle" = 0;
    "net.ipv4.tcp_mtu_probing" = 1;
  };

  zramSwap = {
    enable = true;
    algorithm = "zstd";
  };
  boot.tmpOnTmpfs = true;

  fileSystems."/".options = [ "noatime" "nodiratime" ];
  fileSystems."/home".options = [ "noatime" "nodiratime" ];
}