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