]> Git — Sourcephile - sourcephile-nix.git/blob - nixos/profiles/systems/zfs.nix
carotte: avoid compiling zfs-kernel, and enable gpg-agent
[sourcephile-nix.git] / nixos / profiles / systems / zfs.nix
1 { pkgs, lib, config, ... }:
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
13 # Using ZFS together with hibernation (suspend to disk)
14 # may cause filesystem corruption.
15 # See https://github.com/openzfs/zfs/issues/260
16 boot.kernelParams = [ "nohibernate" ];
17
18 # Ensure extra safeguards are active that zfs uses to protect zfs pools.
19 boot.zfs.forceImportAll = false;
20 boot.zfs.forceImportRoot = false;
21
22 boot.zfs.enableUnstable = false;
23 # Can be overrided with a list of specific datasets
24 boot.zfs.requestEncryptionCredentials = lib.mkDefault true;
25
26 # Enables periodic scrubbing of ZFS pools.
27 services.zfs.autoScrub.enable = true;
28
29 # According to zpool(8), for consumer hardware
30 # periodic manual TRIM is preferred over the automatic TRIM
31 # that ZFS implements.
32 services.zfs.trim.enable = true;
33
34 # Add tools useful with zfs send/receive
35 environment.systemPackages = [
36 pkgs.lzop
37 pkgs.mbuffer
38 ];
39 }