summary refs log tree commit diff stats
path: root/system/settings/hardware/bare-metal.nix
blob: 75c70456afb2de9d43b322a1b709edb8f62b4921 (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
{ config
, pkgs
, ...
}: {
  environment.systemPackages = with pkgs; [
    exfat
    efibootmgr
    dmidecode
    hdparm
    pciutils
    usbutils
  ];

  services.logind = {
    extraConfig = ''
      IdleAction=suspend
      IdleActionSec=1800
      HandlePowerKey=suspend
      HandlePowerKeyLongPress=poweroff
      PowerKeyIgnoreInhibited=yes
    '';
  };
  services.udev.extraRules = ''
    # set scheduler for NVMe
    ACTION=="add|change", KERNEL=="nvme[0-9]n[0-9]", ATTR{queue/scheduler}="kyber"
    ACTION=="add|change", KERNEL=="nvme[0-9]n[0-9]", ATTR{queue/iosched/read_lat_nsec}="100000"
    # 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}="kyber"
  '';

  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;
    "net.core.rmem_max" = 2500000;
    "net.core.wmem_max" = 2500000;
  };

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

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