{ ... }:
{
  _class = "clan.service";
  manifest.name = "paperless";
  manifest.description = "A community-supported supercharged document management system: scan, index and archive all your documents";
  manifest.readme = "A community-supported supercharged document management system: scan, index and archive all your documents";
  manifest.categories = [ "System" ];

  roles.default = {
    description = "a default server role";

    perInstance.nixosModule =
      {
        lib,
        config,
        ...
      }:
      {
        nixpkgs.overlays = [
          (final: prev: {
            pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
              (pyFinal: pyPrev: {
                psycopg = pyPrev.psycopg.overrideAttrs (old: {
                  disabledTests = old.disabledTests ++ [ "test_stats_connect" ];
                });
              })
            ];
          })
        ];

        services.paperless = {
          enable = lib.mkDefault true;
        };

        clan.core.state.paperless.folders = [ config.services.paperless.dataDir ];
      };
  };
}
