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