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