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