]> Git — Sourcephile - julm/julm-nix.git/blob - nixos/profiles/zfs.nix
qpdf: install in office
[julm/julm-nix.git] / nixos / profiles / zfs.nix
1 { pkgs, lib, hostName, ... }:
2 {
3 # none is the recommended elevator with ZFS (which has its own I/O scheduler)
4 # and/or for SSD, whereas HDD could use mq-deadline.
5 services.udev.extraRules = ''
6 # set none scheduler for non-rotating disks
7 ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="none"
8 ACTION=="add|change", KERNEL=="nvme[0-9]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="none"
9 '';
10
11 boot.supportedFilesystems = [ "zfs" ];
12 boot.initrd.supportedFilesystems = [ "zfs" ];
13 boot.zfs.requestEncryptionCredentials = lib.mkDefault [ hostName ];
14
15 # Using ZFS together with hibernation (suspend to disk)
16 # may cause filesystem corruption.
17 # See https://github.com/openzfs/zfs/issues/260
18 boot.kernelParams = [ "nohibernate" ];
19
20 # Ensure extra safeguards are active that zfs uses to protect zfs pools.
21 boot.zfs.forceImportAll = false;
22 boot.zfs.forceImportRoot = false;
23
24 boot.zfs.enableUnstable = false;
25
26 # Enables periodic scrubbing of ZFS pools.
27 services.zfs.autoScrub.enable = true;
28 services.zfs.autoScrub.interval = "Sun *-*-08..14 00:15:00";
29
30 # According to zpool(8), for consumer hardware
31 # periodic manual TRIM is preferred over the automatic TRIM
32 # that ZFS implements.
33 services.zfs.trim.enable = true;
34 services.zfs.trim.interval = "Sun *-*-01..07 00:15:00";
35
36 environment.systemPackages = [
37 pkgs.sanoid
38 ];
39 }