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