1 { config, lib, pkgs, hostName, ... }:
3 hardware.cpu.intel.updateMicrocode = true;
4 powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand";
8 # FIXME: uncomment when updating to 21.05
34 hardware.acpilight.enable = true;
39 event = "video/brightnessdown.*";
40 action = "${pkgs.acpilight}/bin/xbacklight -dec 5";
43 event = "video/brightnessup.*";
44 action = "${pkgs.acpilight}/bin/xbacklight -inc 5";
47 event = "ac_adapter/*";
52 ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g powersave;;
53 00000001) # plugged in
54 ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g ondemand;;
61 # https://bugzilla.kernel.org/show_bug.cgi?id=110941
62 boot.kernelParams = [ "intel_pstate=no_hwp" ];
63 boot.kernelModules = [ "kvm-intel" ];
64 boot.cleanTmpDir = true;
65 boot.tmpOnTmpfs = true;
66 boot.extraModulePackages = [
67 config.boot.kernelPackages.exfat-nofuse
72 device = "/dev/disk/by-id/ata-Samsung_SSD_850_PRO_128GB_S1SMNSAFC36436X";
73 configurationLimit = 3;
78 canTouchEfiVariables = false;
79 efiSysMountPoint = "/boot/efi";
82 #enableCryptodisk = true;
86 { device = "/dev/disk/by-partlabel/${hostName}_ssd_boot";
89 fileSystems."/boot/efi" =
90 { device = "/dev/disk/by-partlabel/${hostName}_ssd_efi";
94 { device = "/dev/disk/by-partlabel/${hostName}_ssd_swap";
97 cipher = "aes-xts-plain64";
98 source = "/dev/urandom";
104 algorithm = lib.mkDefault "zstd";
105 # There is little point creating a zram of greater
106 # than twice the size of memory
107 # since we expect a 2:1 compression ratio.
108 # Note that zram uses about 0.1% of the size of the disk
109 # when not in use so a huge zram is wasteful.
110 memoryPercent = lib.mkDefault 150;
111 # Linux supports multithreaded compression for 1 device since 3.15.
112 # See https://lkml.org/lkml/2014/2/28/404 for details.
113 swapDevices = lib.mkDefault 1;
115 boot.kernel.sysctl = {
116 # Increase cache pressure, which increases the tendency of the kernel to
117 # reclaim memory used for caching of directory and inode objects. You will use
118 # less memory over a longer period of time. The performance hit is negated by
119 # the downside of swapping sooner.
120 "vm.vfs_cache_pressure" = lib.mkDefault 500;
122 # Increasing how aggressively the kernel will swap memory pages since we are
124 "vm.swappiness" = lib.mkDefault 100;
126 # Background processes will start writing right away when it hits the 1% limit
127 "vm.dirty_background_ratio" = lib.mkDefault 1;
129 # The system won’t force synchronous I/O until it gets to 50% dirty_ratio.
130 "vm.dirty_ratio" = lib.mkDefault 50;
133 # The 32-bit host id of the host, formatted as 8 hexadecimal characters.
134 # You should try to make this id unique among your hosts.
135 # Manually generated with : head -c4 /dev/urandom | od -A none -t x4 | cut -d ' ' -f 2
136 networking.hostId = "ce53d0c3";
138 # none is the recommended elevator with ZFS (which has its own I/O scheduler)
139 # and/or for SSD, whereas HDD could use mq-deadline.
140 services.udev.extraRules = ''
141 # set none scheduler for non-rotating disks
142 ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="none"
145 boot.supportedFilesystems = [ "ntfs" "vfat" "zfs" ];
146 boot.initrd.supportedFilesystems = [ "zfs" ];
147 boot.initrd.availableKernelModules = [
156 boot.zfs.forceImportAll = false;
157 boot.zfs.forceImportRoot = false;
158 boot.zfs.enableUnstable = false;
159 boot.zfs.requestEncryptionCredentials = [ hostName ];
160 services.zfs.autoScrub.enable = true;
163 { device = "${hostName}/root";
167 { device = "${hostName}/nix";
171 { device = "${hostName}/var";