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