about summary refs log tree commit diff stats
path: root/modules/by-name/in/invidious-router/module.nix
blob: f85a06cd607bca65e4cbe562cc59a97cce283926 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{
  config,
  lib,
  pkgsUnstable,
  ...
}: let
  cfg = config.vhack.invidious-router;
in {
  options.vhack.invidious-router = {
    enable = lib.mkEnableOption "invidious-router";
    domain = lib.mkOption {
      type = lib.types.str;
      description = "The domain invidious-router should be served on";
    };
    extraDomains = lib.mkOption {
      type = lib.types.listOf lib.types.str;
      default = [];
      description = "Addtional domains invidious-router should be served on";
    };
  };
  config = lib.mkIf cfg.enable {
    services.invidious-router = {
      enable = true;
      package = pkgsUnstable.invidious-router;
      settings = {
        app = {
          listen = "127.0.0.1:8050";
          enable_youtube_fallback = false;
          reload_instance_list_interval = "60s";
          not_available_message = ''
            No available invidious instance found!
            [link]View this video on YouTube[/link], a proprietary
            platform that collects and uses your data without respecting
            your privacy.
          '';
        };
        api = {
          enabled = true;
          url = "https://api.invidious.io/instances.json";
          filter_regions = false;
          allowed_regions = [
            "AT"
            "DE"
            "CH"
          ];
        };
        healthcheck = {
          path = "/watch?v=uSvJaYxRoB4";
          allowed_status_codes = [
            200
          ];
          timeout = "1s";
          interval = "10s";
          filter_by_response_time = {
            enabled = true;
            qty_of_top_results = 4;
          };
          minimum_ratio = 0.2;
          remove_no_ratio = false;
          text_not_present = "YouTube is currently trying to block Invidious instances";
        };
      };
      nginx = {
        enable = true;
        inherit (cfg) domain extraDomains;
      };
    };
    vhack.nginx.enable = true;
  };
}