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