]> Git — Sourcephile - sourcephile-nix.git/blob - base/zfs.nix
nix: revamp the config paths
[sourcephile-nix.git] / base / zfs.nix
1 { pkgs, lib, config, ... }:
2 {
3 # The 32-bit host id of the machine, formatted as 8 hexadecimal characters.
4 # You should try to make this id unique among your machines.
5 # Manually generated with : head -c4 /dev/urandom | od -A none -t x4 | cut -d ' ' -f 2
6 networking.hostId = "69c40b03";
7
8 # none is the recommended elevator with ZFS (which has its own I/O scheduler)
9 # and/or for SSD, whereas HDD could use mq-deadline.
10 services.udev.extraRules = ''
11 # set none scheduler for non-rotating disks
12 ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="none"
13 '';
14
15 boot.supportedFilesystems = [ "zfs" ];
16
17 # Ensure extra safeguards are active that zfs uses to protect zfs pools.
18 boot.zfs.forceImportAll = false;
19 boot.zfs.forceImportRoot = false;
20
21 boot.zfs.enableUnstable = true;
22 boot.zfs.requestEncryptionCredentials = true;
23
24 # Enables periodic scrubbing of ZFS pools.
25 services.zfs.autoScrub.enable = true;
26
27 environment = {
28 systemPackages = [
29 pkgs.mbuffer
30 pkgs.zfs
31 ];
32 };
33 }