]> Git — Sourcephile - julm/julm-nix.git/blob - hosts/patate/hardware.nix
opengl: enable
[julm/julm-nix.git] / hosts / patate / 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 # FIXME: uncomment when updating to 21.05
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 levels = [
27 [0 0 57]
28 [1 56 62]
29 [2 61 65]
30 [3 64 66]
31 [4 65 68]
32 [5 67 71]
33 [6 70 76]
34 [7 75 81]
35 [127 80 32767]
36 ];
37 */
38 };
39
40 # https://bugzilla.kernel.org/show_bug.cgi?id=110941
41 boot.kernelParams = [ "intel_pstate=no_hwp" ];
42 boot.kernelModules = [ "kvm-intel" ];
43 boot.cleanTmpDir = true;
44 boot.tmpOnTmpfs = true;
45 boot.extraModulePackages = [
46 config.boot.kernelPackages.exfat-nofuse
47 ];
48 boot.loader.grub = {
49 enable = true;
50 version = 2;
51 device = "/dev/disk/by-id/ata-CT250MX500SSD1_2004E2849DD1";
52 configurationLimit = 3;
53 #zfsSupport = true;
54 /*
55 efiSupport = true;
56 efi = {
57 canTouchEfiVariables = false;
58 efiSysMountPoint = "/boot/efi";
59 };
60 */
61 #enableCryptodisk = true;
62 };
63 services.acpid = {
64 enable = true;
65 handlers = {
66 brightnessDown = {
67 event = "video/brightnessdown.*";
68 action = "${pkgs.acpilight}/bin/xbacklight -dec 10";
69 };
70 brightnessUp = {
71 event = "video/brightnessup.*";
72 action = "${pkgs.acpilight}/bin/xbacklight -inc 10";
73 };
74 acAdapter = {
75 event = "ac_adapter/*";
76 action = ''
77 vals=($1)
78 case ''${vals[3]} in
79 00000000) # unplugged
80 ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g powersave;;
81 00000001) # plugged in
82 ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g ondemand;;
83 esac
84 '';
85 };
86 };
87 };
88
89 fileSystems."/boot" =
90 { device = "/dev/disk/by-partlabel/${hostName}_ssd_boot";
91 fsType = "ext2";
92 };
93 fileSystems."/boot/efi" =
94 { device = "/dev/disk/by-partlabel/${hostName}_ssd_efi";
95 fsType = "vfat";
96 };
97 swapDevices = [
98 { device = "/dev/disk/by-partlabel/${hostName}_ssd_swap";
99 randomEncryption = {
100 enable = true;
101 cipher = "aes-xts-plain64";
102 source = "/dev/urandom";
103 };
104 }
105 ];
106 zramSwap = {
107 enable = true;
108 algorithm = lib.mkDefault "zstd";
109 # There is little point creating a zram of greater
110 # than twice the size of memory
111 # since we expect a 2:1 compression ratio.
112 # Note that zram uses about 0.1% of the size of the disk
113 # when not in use so a huge zram is wasteful.
114 memoryPercent = lib.mkDefault 150;
115 # Linux supports multithreaded compression for 1 device since 3.15.
116 # See https://lkml.org/lkml/2014/2/28/404 for details.
117 swapDevices = lib.mkDefault 1;
118 };
119 boot.kernel.sysctl = {
120 # Increase cache pressure, which increases the tendency of the kernel to
121 # reclaim memory used for caching of directory and inode objects. You will use
122 # less memory over a longer period of time. The performance hit is negated by
123 # the downside of swapping sooner.
124 "vm.vfs_cache_pressure" = lib.mkDefault 500;
125
126 # Increasing how aggressively the kernel will swap memory pages since we are
127 # using ZRAM first.
128 "vm.swappiness" = lib.mkDefault 100;
129
130 # Background processes will start writing right away when it hits the 1% limit
131 "vm.dirty_background_ratio" = lib.mkDefault 1;
132
133 # The system won’t force synchronous I/O until it gets to 50% dirty_ratio.
134 "vm.dirty_ratio" = lib.mkDefault 50;
135 };
136
137 # The 32-bit host id of the host, formatted as 8 hexadecimal characters.
138 # You should try to make this id unique among your hosts.
139 # Manually generated with : head -c4 /dev/urandom | od -A none -t x4 | cut -d ' ' -f 2
140 networking.hostId = "ec2adb40";
141
142 # none is the recommended elevator with ZFS (which has its own I/O scheduler)
143 # and/or for SSD, whereas HDD could use mq-deadline.
144 services.udev.extraRules = ''
145 # set none scheduler for non-rotating disks
146 ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="none"
147 '';
148
149 boot.supportedFilesystems = [ "ntfs" "vfat" "zfs" ];
150 boot.initrd.supportedFilesystems = [ "zfs" ];
151 boot.initrd.availableKernelModules = [
152 "ahci"
153 "drbg"
154 "ehci_pci"
155 "gf128mul"
156 "hmac"
157 "sd_mod"
158 ];
159
160 boot.zfs.forceImportAll = false;
161 boot.zfs.forceImportRoot = false;
162 boot.zfs.enableUnstable = false;
163 boot.zfs.requestEncryptionCredentials = [ hostName ];
164 services.zfs.autoScrub.enable = true;
165
166 fileSystems."/" =
167 { device = "${hostName}/root";
168 fsType = "zfs";
169 };
170 fileSystems."/nix" =
171 { device = "${hostName}/nix";
172 fsType = "zfs";
173 };
174 fileSystems."/home/sevy" =
175 { device = "${hostName}/home";
176 fsType = "zfs";
177 };
178 fileSystems."/home/sevy/Documents" =
179 { device = "${hostName}/home/Documents";
180 fsType = "zfs";
181 };
182 fileSystems."/home/sevy/Images" =
183 { device = "${hostName}/home/Images";
184 fsType = "zfs";
185 };
186 fileSystems."/home/sevy/Téléchargements" =
187 { device = "${hostName}/home/Downloads";
188 fsType = "zfs";
189 };
190 fileSystems."/home/sevy/.thunderbird" =
191 { device = "${hostName}/home/Mails";
192 fsType = "zfs";
193 };
194 fileSystems."/home/sevy/Vidéos" =
195 { device = "${hostName}/home/Videos";
196 fsType = "zfs";
197 };
198 fileSystems."/var" =
199 { device = "${hostName}/var";
200 fsType = "zfs";
201 };
202 fileSystems."/var/cache" =
203 { device = "${hostName}/var/cache";
204 fsType = "zfs";
205 };
206 fileSystems."/var/log" =
207 { device = "${hostName}/var/log";
208 fsType = "zfs";
209 };
210 fileSystems."/var/tmp" =
211 { device = "${hostName}/var/tmp";
212 fsType = "zfs";
213 };
214
215 }