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