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