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