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