1 { config, lib, pkgs, hostName, ... }:
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)
10 powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand";
14 # FIXME: uncomment when updating to 21.05
40 hardware.acpilight.enable = true;
45 event = "video/brightnessdown.*";
46 action = "${pkgs.acpilight}/bin/xbacklight -dec 5";
49 event = "video/brightnessup.*";
50 action = "${pkgs.acpilight}/bin/xbacklight -inc 5";
53 event = "ac_adapter/*";
58 ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g powersave;;
59 00000001) # plugged in
60 ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g ondemand;;
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
78 device = "/dev/disk/by-id/ata-Samsung_SSD_850_PRO_128GB_S1SMNSAFC36436X";
79 configurationLimit = 3;
84 canTouchEfiVariables = false;
85 efiSysMountPoint = "/boot/efi";
88 #enableCryptodisk = true;
92 { device = "/dev/disk/by-partlabel/${hostName}_ssd_boot";
95 fileSystems."/boot/efi" =
96 { device = "/dev/disk/by-partlabel/${hostName}_ssd_efi";
100 { device = "/dev/disk/by-partlabel/${hostName}_ssd_swap";
103 cipher = "aes-xts-plain64";
104 source = "/dev/urandom";
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;
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;
128 # Increasing how aggressively the kernel will swap memory pages since we are
130 "vm.swappiness" = lib.mkDefault 100;
132 # Background processes will start writing right away when it hits the 1% limit
133 "vm.dirty_background_ratio" = lib.mkDefault 1;
135 # The system won’t force synchronous I/O until it gets to 50% dirty_ratio.
136 "vm.dirty_ratio" = lib.mkDefault 50;
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";
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"
151 boot.supportedFilesystems = [ "ntfs" "vfat" "zfs" ];
152 boot.initrd.supportedFilesystems = [ "zfs" ];
153 boot.initrd.availableKernelModules = [
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;
169 { device = "${hostName}/root";
173 { device = "${hostName}/nix";
177 { device = "${hostName}/var";