services.sanoid = {
    enable = true;
    allowPermissions = [ "bpool" "fpool" ];
    config = let
      recursive = { recursive = true; };
      template = name: { use_template = name; };
    in rec {
      bpool = recursive // (template "basic");
      fpool = recursive // (template "basic");
      "fpool/enc/home" = template "high";
      "fpool/enc/nix" = template "shortterm";
      "fpool/enc/root" = template "high";

      # "fpool/enc/vault" = template "longterm";

      template_basic = {
        autosnap = true;
        autoprune = true;
        frequently = 0;
        hourly = 24;
        daily = 31;
        monthly = 2;
      };

      template_high = template_basic // {
        # Keep 48h of snapshots made every 5 minutes
        frequent_period = 5;
        frequently = 48 * 60 / 5;

        # 1 week of hourly snapshots
        hourly = 7 * 24;

        daily = 60;
        monthly = 12;
        yearly = 0;
      };

      template_shortterm = template_basic // {
        hourly = 24;
        daily = 0;
        monthly = 0;
        yearly = 0;
      };

      template_longterm = template_high // {
        daily = 365;
        monthly = 10 * 12;
        yearly = 100;
      };
    };
  };