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