]> Git — Sourcephile - julm/julm-nix.git/blob - machines/oignon/hardware.nix
fix zfs set reservation
[julm/julm-nix.git] / machines / oignon / hardware.nix
1 { config, lib, pkgs, machineName, ... }:
2 {
3 hardware.cpu.intel.updateMicrocode = true;
4 powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand";
5 nix.maxJobs = lib.mkDefault 2;
6 services.thinkfan = {
7 enable = true;
8 levels = ''
9 (0, 0, 52)
10 (1, 50, 58)
11 (2, 56, 60)
12 (3, 58, 62)
13 (6, 60, 72)
14 (7, 70, 85)
15 (127, 80, 32767)
16 '';
17 };
18
19 # https://bugzilla.kernel.org/show_bug.cgi?id=110941
20 boot.kernelParams = [ "intel_pstate=no_hwp" ];
21 boot.kernelModules = [ "kvm-intel" ];
22 boot.cleanTmpDir = true;
23 boot.tmpOnTmpfs = true;
24 boot.extraModulePackages = [
25 config.boot.kernelPackages.exfat-nofuse
26 ];
27 boot.loader.grub = {
28 enable = true;
29 version = 2;
30 device = "/dev/disk/by-id/ata-Samsung_SSD_850_PRO_128GB_S1SMNSAFC36436X";
31 configurationLimit = 3;
32 #zfsSupport = true;
33 /*
34 efiSupport = true;
35 efi = {
36 canTouchEfiVariables = false;
37 efiSysMountPoint = "/boot/efi";
38 };
39 */
40 #enableCryptodisk = true;
41 };
42
43 fileSystems."/boot" =
44 { device = "/dev/disk/by-partlabel/${machineName}_ssd_boot";
45 fsType = "ext2";
46 };
47 fileSystems."/boot/efi" =
48 { device = "/dev/disk/by-partlabel/${machineName}_ssd_efi";
49 fsType = "vfat";
50 };
51 swapDevices = [
52 { device = "/dev/disk/by-partlabel/${machineName}_ssd_swap";
53 randomEncryption = {
54 enable = true;
55 cipher = "aes-xts-plain64";
56 source = "/dev/urandom";
57 };
58 }
59 ];
60 zramSwap = {
61 enable = true;
62 algorithm = lib.mkDefault "zstd";
63 # There is little point creating a zram of greater
64 # than twice the size of memory
65 # since we expect a 2:1 compression ratio.
66 # Note that zram uses about 0.1% of the size of the disk
67 # when not in use so a huge zram is wasteful.
68 memoryPercent = lib.mkDefault 150;
69 # Linux supports multithreaded compression for 1 device since 3.15.
70 # See https://lkml.org/lkml/2014/2/28/404 for details.
71 swapDevices = lib.mkDefault 1;
72 };
73 boot.kernel.sysctl = {
74 # Increase cache pressure, which increases the tendency of the kernel to
75 # reclaim memory used for caching of directory and inode objects. You will use
76 # less memory over a longer period of time. The performance hit is negated by
77 # the downside of swapping sooner.
78 "vm.vfs_cache_pressure" = lib.mkDefault 500;
79
80 # Increasing how aggressively the kernel will swap memory pages since we are
81 # using ZRAM first.
82 "vm.swappiness" = lib.mkDefault 100;
83
84 # Background processes will start writing right away when it hits the 1% limit
85 "vm.dirty_background_ratio" = lib.mkDefault 1;
86
87 # The system won’t force synchronous I/O until it gets to 50% dirty_ratio.
88 "vm.dirty_ratio" = lib.mkDefault 50;
89 };
90
91 # The 32-bit host id of the machine, formatted as 8 hexadecimal characters.
92 # You should try to make this id unique among your machines.
93 # Manually generated with : head -c4 /dev/urandom | od -A none -t x4 | cut -d ' ' -f 2
94 networking.hostId = "ce53d0c3";
95
96 # none is the recommended elevator with ZFS (which has its own I/O scheduler)
97 # and/or for SSD, whereas HDD could use mq-deadline.
98 services.udev.extraRules = ''
99 # set none scheduler for non-rotating disks
100 ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="none"
101 '';
102
103 boot.supportedFilesystems = [ "zfs" ];
104 boot.initrd.supportedFilesystems = [ "zfs" ];
105 boot.initrd.availableKernelModules = [
106 "ahci"
107 "drbg"
108 "ehci_pci"
109 "gf128mul"
110 "hmac"
111 "sd_mod"
112 ];
113
114 boot.zfs.forceImportAll = false;
115 boot.zfs.forceImportRoot = false;
116 boot.zfs.enableUnstable = false;
117 boot.zfs.requestEncryptionCredentials = true;
118 services.zfs.autoScrub.enable = true;
119
120 fileSystems."/" =
121 { device = "${machineName}/root";
122 fsType = "zfs";
123 };
124 fileSystems."/nix" =
125 { device = "${machineName}/nix";
126 fsType = "zfs";
127 };
128 /* Mounted by zfs-mount.service
129 fileSystems."/home" =
130 { device = "${machineName}/home";
131 fsType = "zfs";
132 };
133 fileSystems."/home/julm/documents" =
134 { device = "${machineName}/home/documents";
135 fsType = "zfs";
136 };
137 */
138 fileSystems."/var" =
139 { device = "${machineName}/var";
140 fsType = "zfs";
141 };
142
143 }