summaryrefslogtreecommitdiff
path: root/os/srv/zfs.nix
blob: fadfd82687c557d538bf09559410ce820e56ab97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{ config, lib, ... }:
let
  cfg = config.os.srv.zfs;
in
{
  options.os.srv.zfs.enable = lib.mkEnableOption "enables zfs drive maintnance";
  config = lib.mkIf cfg.enable {
    assertions = [
      {
        assertion = config.os.core.drivers.kernel == "zfs";
        message = "ZFS requires the zfs supported kernel";
      }
    ];
    boot = {
      kernelParams = [ "zfs.zfs_arc_max=34359738368" ];
      supportedFilesystems = [ "zfs" ];
      initrd = {
        supportedFilesystems = [ "zfs" ];
        # fileSystems."/mnt" = {
        #   device = "/dev/disk/by-label/KEYS";
        #   fsType = "vfat";
        #   options = [ "ro" ];
        # };
      };
    };
    services.zfs = {
      autoScrub = {
        enable = true;
        interval = "weekly";
      };
      trim.enable = true;
      zed = {
        enableMail = true;
        settings = {
          ZED_DEBUG_LOG = "/var/log/zed.debug.log";

          ZED_EMAIL_ADDR = [ "adikro@disroot.org" ];
          ZED_EMAIL_PROG = "mail";
          ZED_EMAIL_OPTS = "-s '@SUBJECT@' @ADDRESS@";

          ZED_NOTIFY_INTERVAL_SECS = 3600;
          ZED_NOTIFY_VERBOSE = false;

          ZED_USE_ENCLOSURE_LEDS = true;
          ZED_SCRUB_AFTER_RESILVER = false;

        };
      };
    };
    networking.hostId = "4e3e22e1";
  };
}