{
  config,
  pkgs,
  ...
}: let
  backupConfig = {
    paths = ["/home"];
    exclude = [
      "/home/*/Videos"
      ".cache"
      ".rustup"
      ".cargo"
      ".config/Element/Cache"
      ".config/discord/Cache"
    ];
    timerConfig = {OnCalendar = "daily";};
    pruneOpts = [
      "--keep-daily 8"
      "--keep-weekly 5"
      "--keep-monthly 13"
      "--keep-yearly 2"
    ];
    checkOpts = [
      "--with-cache"
    ];
  };
  niceness = {
    Nice = 19;
    IOSchedulingClass = "idle";
  };
in {
  services = {
    restic.backups.home-to-bolty =
      {
        passwordFile = "/etc/nixos/secrets/restic-password-bolty";
        repository = "rest:http://bolty:8000/";
      }
      // backupConfig;

    restic.backups.home-to-b2 =
      {
        passwordFile = "/etc/nixos/secrets/restic-password-b2";
        repository = "b2:cyplo-restic-${config.networking.hostName}:/";
        environmentFile = "/etc/nixos/secrets/b2-env";
      }
      // backupConfig;
  };

  systemd.services.restic-backups-home-to-bolty.serviceConfig = niceness;
  systemd.services.restic-backups-home-to-b2.serviceConfig = niceness;
}
