{ pkgs, lib, config, ... }:
{
  config = {
    fileSystems = {
      "/boot" =
        { device = "boot";
          fsType = "zfs";
        };

      "/nix" =
        { device = "ssd-raid0/local/nix";
          fsType = "zfs";
        };

      "/root" =
        { device = "ssd-raid1/safe/home-root";
          fsType = "zfs";
          neededForBoot = true;
        };

      "/var/lib/systemd" =
        { device = "ssd-raid1/local/var-lib-systemd";
          fsType = "zfs";
          neededForBoot = true;
        };

      "/var/lib/nixos" =
        { device = "ssd-raid1/local/var-lib-nixos";
          fsType = "zfs";
          neededForBoot = true;
        };

      "/var/lib/unbound" =
        { device = "ssd-raid1/local/var-lib-unbound";
          fsType = "zfs";
        };

      # "/var/lib/dhcp" =
      #   { device = "ssd-raid1/local/var-lib-dhcp";
      #     fsType = "zfs";
      #   };

      "/var/lib/chrony" =
        { device = "ssd-raid1/local/var-lib-chrony";
          fsType = "zfs";
        };

      "/var/lib/samba" =
        { device = "ssd-raid1/local/var-lib-samba";
          fsType = "zfs";
        };

      # "/var/lib/prometheus2" =
      #   { device = "ssd-raid1/local/var-lib-prometheus2";
      #     fsType = "zfs";
      #     options = [ "zfsutil" ];
      #   };

      # "/var/lib/grafana" =
      #   { device = "ssd-raid1/local/var-lib-grafana";
      #     fsType = "zfs";
      #     options = [ "zfsutil" ];
      #   };

      # "/var/lib/loki" =
      #   { device = "ssd-raid1/local/var-lib-loki";
      #     fsType = "zfs";
      #     options = [ "zfsutil" ];
      #   };

      # "/srv/tftp" =
      #   { device = "ssd-raid1/local/srv-tftp";
      #     fsType = "zfs";
      #     options = [ "zfsutil" ];
      #   };

      "/var/log" =
        { device = "ssd-raid1/local/var-log";
          fsType = "zfs";
        };

      # "/home" =
      #   { device = "hdd-raid6/safe/home";
      #     fsType = "zfs";
      #     options = [ "zfsutil" ];
      #   };

      # "/home/gkleen" =
      #   { device = "hdd-raid6/safe/home/gkleen";
      #     fsType = "zfs";
      #     options = [ "zfsutil" ];
      #   };

      # "/home/mherold" =
      #   { device = "hdd-raid6/safe/home/mherold";
      #     fsType = "zfs";
      #     options = [ "zfsutil" ];
      #   };

      "/home/mherold/camera/2020-09-13" =
        { device = "/dev/zvol/hdd-raid6/safe/home/mherold/camera/2020-09-13";
          fsType = "vfat";
          options = [ "uid=mherold" "gid=users" "x-systemd.automount" "x-systemd.idle-timeout=120" ];
          noCheck = true;
        };

      "/home/mherold/camera/2022-01-16" =
        { device = "/dev/zvol/hdd-raid6/safe/home/mherold/camera/2022-01-16";
          fsType = "vfat";
          options = [ "uid=mherold" "gid=users" "x-systemd.automount" "x-systemd.idle-timeout=120" ];
          noCheck = true;
        };

      "/home/mherold/camera/2022-05-15" =
        { device = "/dev/zvol/hdd-raid6/safe/home/mherold/camera/2022-05-15";
          fsType = "vfat";
          options = [ "uid=mherold" "gid=users" "x-systemd.automount" "x-systemd.idle-timeout=120" ];
          noCheck = true;
        };
    };

    users.users.gkleen.createHome = lib.mkForce false;
    users.users.mherold.createHome = lib.mkForce false;

    boot.postBootCommands = ''
      echo "=== STARTING ZPOOL IMPORT ==="
      ${pkgs.zfs}/bin/zpool import -a -N -d /dev
      ${pkgs.zfs}/bin/zpool status
      ${pkgs.zfs}/bin/zfs mount -a
      echo "=== ZPOOL IMPORT COMPLETE ==="
    '';

    services.zfssnap = {
      enable = true;
      config.keep = {
        within = "15m";
        "5m" = "48";
        "15m" = "32";
        hourly = "48";
        "4h" = "24";
        "12h" = "12";
        daily = "62";
        halfweekly = "32";
        weekly = "24";
        monthly = "-1";
      };
    };
    services.zfs.trim.enable = false;
    services.zfs.autoScrub = {
      enable = true;
      interval = "Sun *-*-1..7 04:00:00";
    };
    services.zfs.zed.settings = {
      ZED_SYSLOG_SUBCLASS_EXCLUDE = "history_event";
    };
  };
}