{ config, lib, pkgs, ... }:

{
  # ZFS automatic backup solution
  services.znapzend = {
    enable = true;
    autoCreation = true;
    features = {
      compressed = true;
      recvu = true;
    };
    zetup = {
      "syscea/stateful/root" = {
        plan = "1day=>1hour,2week=>1day,1month=>1week,1year=>1month";
        recursive = true;
        mbuffer.enable = true;
      };

      "syscea/stateful/home" = {
        plan = "1day=>1hour,2week=>1day,1month=>1week,1year=>1month";
        recursive = true;
        mbuffer.enable = true;
      };
    };
  };

  # Syncthing configuration
  services.syncthing = {
    enable = true;
    user = "coolneng";
    dataDir = "/home/coolneng";
    declarative = {
      devices = {
        zion = {
          id =
            "XABIMVG-K5RKMAF-KNC33AR-TDAVEGK-GHUIVFD-NIFCX6L-6PQXRM5-KLK2PAU";
          addresses = [ "tcp://coolneng.duckdns.org:22000" ];
        };
      };
      folders = {
        Documents = {
          id = "wusdj-bfjkr";
          path = "/home/coolneng/Documents";
          devices = [ "zion" ];
          versioning = {
            type = "simple";
            params = { keep = "5"; };
          };
        };

        Notes = {
          id = "kafhz-bfmzm";
          path = "/home/coolneng/Notes";
          devices = [ "zion" ];
          versioning = {
            type = "simple";
            params = { keep = "5"; };
          };
        };

        Music = {
          id = "2aqt7-vpprc";
          path = "/home/coolneng/Music";
          devices = [ "zion" ];
        };

        Photos = {
          id = "mjibc-ustcg";
          path = "/home/coolneng/Photos";
          devices = [ "zion" ];
        };

        Projects = {
          id = "cjhmu-avy9v";
          path = "/home/coolneng/Projects";
          devices = [ "zion" ];
        };
      };
    };
  };
}