]> Git — Sourcephile - julm/julm-nix.git/blob - hosts/oignon/hardware.nix
sshd: start only after wg-intra
[julm/julm-nix.git] / hosts / oignon / hardware.nix
1 { config, lib, pkgs, hostName, ... }:
2 {
3 hardware.cpu.intel.updateMicrocode = true;
4 hardware.opengl.extraPackages = [
5 pkgs.intel-media-driver # LIBVA_DRIVER_NAME=iHD
6 pkgs.vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
7 pkgs.vaapiVdpau
8 pkgs.libvdpau-va-gl
9 ];
10 powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand";
11 services.thinkfan = {
12 enable = true;
13 smartSupport = true;
14 levels = [
15 [0 0 57]
16 [1 56 62]
17 [2 61 65]
18 [3 64 66]
19 [4 65 68]
20 [5 67 71]
21 [6 70 76]
22 [7 75 81]
23 [127 80 32767]
24 ];
25 };
26 hardware.acpilight.enable = true;
27 services.acpid = {
28 enable = true;
29 handlers = {
30 brightnessDown = {
31 event = "video/brightnessdown.*";
32 action = "${pkgs.acpilight}/bin/xbacklight -dec 5";
33 };
34 brightnessUp = {
35 event = "video/brightnessup.*";
36 action = "${pkgs.acpilight}/bin/xbacklight -inc 5";
37 };
38 acAdapter = {
39 event = "ac_adapter/*";
40 action = ''
41 vals=($1)
42 case ''${vals[3]} in
43 00000000) # unplugged
44 ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g powersave;;
45 00000001) # plugged in
46 ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g ondemand;;
47 esac
48 '';
49 };
50 };
51 };
52
53 # https://bugzilla.kernel.org/show_bug.cgi?id=110941
54 boot.kernelParams = [ "intel_pstate=no_hwp" ];
55 boot.kernelModules = [ "kvm-intel" ];
56 boot.cleanTmpDir = true;
57 boot.tmpOnTmpfs = true;
58 boot.extraModulePackages = [
59 #config.boot.kernelPackages.exfat-nofuse
60 ];
61 boot.loader.grub = {
62 enable = true;
63 version = 2;
64 device = "/dev/disk/by-id/ata-Samsung_SSD_850_PRO_128GB_S1SMNSAFC36436X";
65 configurationLimit = 3;
66 #zfsSupport = true;
67 /*
68 efiSupport = true;
69 efi = {
70 canTouchEfiVariables = false;
71 efiSysMountPoint = "/boot/efi";
72 };
73 */
74 #enableCryptodisk = true;
75 };
76
77 fileSystems."/boot" =
78 { device = "/dev/disk/by-partlabel/${hostName}_ssd_boot";
79 fsType = "ext2";
80 };
81 fileSystems."/boot/efi" =
82 { device = "/dev/disk/by-partlabel/${hostName}_ssd_efi";
83 fsType = "vfat";
84 };
85 swapDevices = [
86 { device = "/dev/disk/by-partlabel/${hostName}_ssd_swap";
87 randomEncryption = {
88 enable = true;
89 cipher = "aes-xts-plain64";
90 source = "/dev/urandom";
91 };
92 }
93 ];
94 zramSwap = {
95 enable = true;
96 algorithm = lib.mkDefault "zstd";
97 # There is little point creating a zram of greater
98 # than twice the size of memory
99 # since we expect a 2:1 compression ratio.
100 # Note that zram uses about 0.1% of the size of the disk
101 # when not in use so a huge zram is wasteful.
102 memoryPercent = lib.mkDefault 150;
103 # Linux supports multithreaded compression for 1 device since 3.15.
104 # See https://lkml.org/lkml/2014/2/28/404 for details.
105 swapDevices = lib.mkDefault 1;
106 };
107 boot.kernel.sysctl = {
108 # Increase cache pressure, which increases the tendency of the kernel to
109 # reclaim memory used for caching of directory and inode objects. You will use
110 # less memory over a longer period of time. The performance hit is negated by
111 # the downside of swapping sooner.
112 "vm.vfs_cache_pressure" = lib.mkDefault 500;
113
114 # Increasing how aggressively the kernel will swap memory pages since we are
115 # using ZRAM first.
116 "vm.swappiness" = lib.mkDefault 100;
117
118 # Background processes will start writing right away when it hits the 1% limit
119 "vm.dirty_background_ratio" = lib.mkDefault 1;
120
121 # The system won’t force synchronous I/O until it gets to 50% dirty_ratio.
122 "vm.dirty_ratio" = lib.mkDefault 50;
123 };
124
125 # The 32-bit host id of the host, formatted as 8 hexadecimal characters.
126 # You should try to make this id unique among your hosts.
127 # Manually generated with : head -c4 /dev/urandom | od -A none -t x4 | cut -d ' ' -f 2
128 networking.hostId = "ce53d0c3";
129
130 # none is the recommended elevator with ZFS (which has its own I/O scheduler)
131 # and/or for SSD, whereas HDD could use mq-deadline.
132 services.udev.extraRules = ''
133 # set none scheduler for non-rotating disks
134 ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="none"
135 '';
136
137 boot.supportedFilesystems = [ "ntfs" "vfat" "zfs" ];
138 boot.initrd.supportedFilesystems = [ "zfs" ];
139 boot.initrd.availableKernelModules = [
140 "ahci"
141 "drbg"
142 "ehci_pci"
143 "gf128mul"
144 "hmac"
145 "sd_mod"
146 ];
147
148 boot.zfs.forceImportAll = false;
149 boot.zfs.forceImportRoot = false;
150 boot.zfs.enableUnstable = false;
151 boot.zfs.requestEncryptionCredentials = [ hostName ];
152 services.zfs.autoScrub.enable = true;
153
154 fileSystems."/" =
155 { device = "${hostName}/root";
156 fsType = "zfs";
157 };
158 fileSystems."/nix" =
159 { device = "${hostName}/nix";
160 fsType = "zfs";
161 };
162 fileSystems."/var" =
163 { device = "${hostName}/var";
164 fsType = "zfs";
165 };
166
167 }